Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The SegaPore Post charges different postal rates for mails of different types. T

ID: 2079960 • Letter: T

Question

The SegaPore Post charges different postal rates for mails of different types. These rates are summarised in the table below. Write a Java application that reads in the mail type and quantity charged for one day. A switch structure should be used to determine the retail price for each mail. An input other than 1, 2 and 3, as mail type will stop all input prompts. The application will then display, on the console screen, the total retail value of mails entered before exiting. You can use the method read integer () provided in the Console class to read in the integers entered at the Console prompt. public class Console {public int readInteger() {...} ...}

Explanation / Answer

import java.util.*; import java.lang.*; import java.io.*; class Console {     static double total;     public int readInteger(){         Scanner in=new Scanner(System.in);         total=0.00;         int i;         int k;         int check=0;         while(true){             System.out.println("Enter the mail type");             i=in.nextInt();             switch(i){                 case 1:                     System.out.println("Enter the no of days");                     k=in.nextInt();                     total=total+ ((float)k * 0.22);                     break;                  case 2:                     System.out.println("Enter the no of days");                     k=in.nextInt();                     total=total+ ((float)k * 0.60);                     break;                  case 3:                     System.out.println("Enter the no of days");                     k=in.nextInt();                     total=total+ ((float)k * 1.20);                     break;                 default:                     System.out.println("The total retail price is "+total+"$");                     check=1;                     break;             }             if(check==1)                 break;         }         return 0;     }    public static void main (String[] args) throws java.lang.Exception    {        Console obj=new Console();        obj.readInteger();    } }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote