Ishmam_Rahman

JAVA HW1_3

May 6th, 2021 (edited)
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.50 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3.  
  4. public class StudentGrade {
  5.     public static void main(String[] args) {
  6.        
  7.         char category;
  8.         double  tc, cpu;
  9.         double bill=0.0;
  10.        
  11.         Scanner scanner;
  12.         scanner = new Scanner(System.in);
  13.        
  14.         System.out.println("Enter category: ");
  15.         category = scanner.next().charAt(0);
  16.        
  17.         System.out.println("Enter total used: ");
  18.         tc = scanner.nextDouble();
  19.  
  20.         switch (category) {
  21.         case 'A':
  22.             if(tc>600){ bill+=(tc-600)*9.98; tc=600;}
  23.             if(tc>400){ bill+=(tc-400)*8.70; tc=400;}
  24.             if(tc>300){ bill+=(tc-300)*5.63; tc=300;}
  25.             if(tc>200){ bill+=(tc-200)*5.36; tc=200;}
  26.             if(tc>75){ bill+=(tc-75)*5.14; tc=75;}
  27.             bill+=(tc*3.80);
  28.             bill+= (20*bill)/100;
  29.             break;
  30.            
  31.         case 'B':
  32.             bill += (tc*3.82);
  33.             break;
  34.         case 'C':
  35.             char type;
  36.             System.out.println("Enter type: ");
  37.             type = scanner.next().charAt(0);
  38.            
  39.             switch(type){
  40.                 case 'A':
  41.                     bill += (tc*7.66);
  42.                     break;
  43.                 case 'B':
  44.                     bill += (tc*6.90);
  45.                     break;
  46.                 case 'C':
  47.                     bill += (tc*9.24);
  48.                     break;
  49.             }
  50.             break;
  51.         }
  52.         System.out.println("Total bill: "+bill);
  53.     }
  54. }
Add Comment
Please, Sign In to add comment