Chapter 6 Ict Programs
Chapter 6 Ict Programs
Question 1
Define a class Calculate to accept two numbers as instance variables. Use the
following member methods for the given purposes:
Member methods:
void inputdata() — to input both the values
void calculate() — to find sum and difference
void outputdata() — to print sum and difference of both the numbers
Use a main method to call the functions.
import java.util.Scanner;
Member Methods:
void getdata() — to accept three numbers
void findprint() — to check and display whether the numbers are Pythagorean
Triplets or not.
import java.util.Scanner;
Output:
import java.util.Scanner;
interest = (p * r * t) / 100.0;
amt = p + interest;
}
Days Fine
First seven days 25 paise per day
Eight to fifteen days 40 paise per day
Sixteen to thirty days 60 paise per day
More than thirty days 80 paise per day
import java.util.Scanner;
public class Library
{
private String name;
private int price;
private int day;
private double fine;
case 4:
newCost = cost + (cost * 0.12);
break;
default:
System.out.println("Incorrect type");
break;
}
}
public void printcost() {
System.out.println("Type: " + type);
System.out.println("New cost: " + newCost);
}
Days Charge
For first five days ₹500 per day
For next five days ₹400 per day
Rest of the days ₹200 per day
Output:
Data Members:
void getdata() — To accept title, author, publisher's name and the number of
copies.
void purchase(int t, String a, String p, int n) — To check the existence of the
book in the stock by comparing total, author's and publisher's name. Also
check whether noc >n or not. If yes, maintain the balance as noc-n, otherwise
display book is not available or stock is under flowing.
Write a program to perform the task given above.
import java.util.Scanner;
Data Members:
import java.util.Scanner;
public class Student
{
private String name;
private int eng;
private int hn;
private int mts;
private double total;
private double avg;
import java.util.Scanner;
import java.util.Scanner;