COMSATS University Islamabad
Attock Campus
Department Of Computer Science
Instructor Umer zia
theory 04
Assignment
Submitted by:
Registration No. Name
FA23-BCS-023 M.Raffay
static double[] discount = new double[3];
static double[] book = new double[3];
double[] discounted = new double[3];
double[] tot_salary = new double[3];
static Scanner scan = new Scanner(System.in);
public static double[] BOOK() {
for (int i = 0; i < 3; i++) {
System.out.println("Enter the salary of books: " + (i + 1));
book[i] = scan.nextDouble();
return book;
public static double[] DISCOUNT(double[] Book) {
for (int i = 0; i < 3; i++) {
if (Book[i] <= 100) {
discount[i] = Book[i] * 0.05;
} else if (Book[i] >= 100 && Book[i] <= 250) {
discount[i] = Book[i] * 0.1;
} else if (Book[i] >= 250 && Book[i] <= 500) {
discount[i] = Book[i] * 0.15;
} else if (Book[i] >= 500) {
discount[i] = Book[i] * 0.2;
} else {
discount[i] = 0;
}
return discount;
public static double[] TotalSalary(double[] salary, double[] tax,double[] tot_salary ) {
for (int i = 0; i < salary.length; i++) {
tot_salary[i] = salary[i] - tax[i];
return tot_salary;
public static double[] FInal(double[] discount, double[] Book,double[] discounted) {
for (int i = 0; i < Book.length; i++) {
discounted[i] = Book[i] - discount[i];
return discounted;
double[] books = BOOK();
double[] discount = DISCOUNT(books);
double[] Final = FInal(discount, books);
System.out.println (
"Name \t Quantity \t Price \t Total Price \t Discount \t Final Price");
for (int i = 0;
i< number ;
i
++) {
System.out.println(name[i] + " \t" + quantity[i] + "\t\t" + price[i] + "\t\t" + books[i] + "\t\t" + discount[i]
+ "\t\t" + Final[i]);
}Output: