Java Assignment1
Java Assignment1
Scanner;
if (paymentOption == 1) {
double installmentAmount = totalCost / 3;
System.out.println("You can pay in 3 equal monthly installments of
Ksh " + installmentAmount);
} else if (paymentOption == 2) {
System.out.println("Please make a full payment of Ksh " +
totalCost);
} else {
System.out.println("Invalid payment option");
}
}
public static double calculateCost(int units, int cost1, int cost2,
int cost3) {
double cost = 0;
if (units <= 100) {
cost = units * cost1;
} else if (units <= 300) {
cost = 100 * cost1 + (units - 100) * cost2;
} else {
cost = 100 * cost1 + 200 * cost2 + (units - 300) * cost3;
}
return cost;
}
}