Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package CBasicsExamONEFOURAprilMorning;
- import java.util.Scanner;
- public class FruitMarket {
- public static void main(String[] args) {
- double banana = 1.80;
- double cucumber = 2.75;
- double tomato = 3.20;
- double orange = 1.60;
- double apple = 0.86;
- double firstnum = 0;
- double secoundnum = 0;
- double thirdnum = 0;
- double sum = 0;
- Scanner scan = new Scanner(System.in);
- String dayOfWeek = scan.nextLine();
- double q1 = scan.nextDouble();
- String p1 = scan.next();
- double q2 = scan.nextDouble();
- String p2 = scan.next();
- double q3 = scan.nextDouble();
- String p3 = scan.next();
- switch (dayOfWeek) {
- case "Tuesday":
- banana *= 0.8;
- orange *= 0.8;
- apple *= 0.8;
- break;
- case "Wednesday":
- tomato *= 0.1;
- cucumber *= 0.1;
- break;
- case "Thursday":
- banana *= 0.7;
- break;
- }
- switch (p1) {
- case "banana":
- firstnum = banana * q1;
- break;
- case "cucumber":
- firstnum = cucumber * q1;
- break;
- case "tomato":
- firstnum = tomato * q1;
- break;
- case "orange":
- firstnum = orange * q1;
- break;
- case "apple":
- firstnum = apple * q1;
- break;
- }
- switch (p2) {
- case "banana":
- secoundnum = banana * q2;
- break;
- case "cucumber":
- secoundnum = cucumber * q2;
- break;
- case "tomato":
- secoundnum = tomato * q2;
- break;
- case "orange":
- secoundnum = orange * q2;
- break;
- case "apple":
- secoundnum = apple * q2;
- break;
- }
- switch (p3) {
- case "banana":
- thirdnum = banana * q3;
- break;
- case "cucumber":
- thirdnum = cucumber * q3;
- break;
- case "tomato":
- thirdnum = tomato * q3;
- break;
- case "orange":
- thirdnum = orange * q3;
- break;
- case "apple":
- thirdnum = apple * q3;
- break;
- }
- sum = firstnum + secoundnum + thirdnum;
- switch (dayOfWeek) {
- case "Friday":
- System.out.printf("%.2f", (sum - (sum * 0.1)));
- break;
- case "Sunday":
- System.out.printf("%.2f", (sum - (sum * 0.05)));
- break;
- case "Tuesday":
- System.out.printf("%.2f", sum);
- break;
- case "Wednesday":
- System.out.printf("%.2f", sum);
- break;
- case "Thursday":
- System.out.printf("%.2f", sum);
- break;
- case "Monday":
- System.out.printf("%.2f", sum);
- break;
- case "Saturday":
- System.out.printf("%.2f", sum);
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement