Answer to Question #247524 in Java | JSP | JSF for roni

Question #247524
Write a pseudocode that calculates and prints the bill for a cellular telephone company. The company offers two types of service: regular and premium. Rates vary based on the type of service and are computed as follows:



Regular service: $10.00 plus first 50 minutes are free. Charges for over 50 minutes are $0.20 per minute.

Premium service: $25.00 plus:

a. For calls made from 6:00 a.m. to 6:00 p.m., the first 75 minutes are free; charges for over 75 minutes are $0.10 per minute.

b. For calls made from 6:00 p.m. to 6:00 a.m., the first 100 minutes are free; charges for over 100 minutes are $0.05 per minute.
1
Expert's answer
2021-10-06T06:24:31-0400
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) {
	    Scanner in=new Scanner(System.in);
		System.out.println("Choose type of service:\n1. Regular\n2. Premium");
		int c=in.nextInt();
		
		double regular_price=10;
		double premium_price=25;
		if(c==1){
		    int minutes;
		    System.out.println("Enter number of minutes:");
		    minutes=in.nextInt();
		    int min;
		    if (minutes>50){
		        min=minutes-50;
		        regular_price=regular_price+(min*0.20);
		    }
		    System.out.println("Bill: "+regular_price);
		}
		else if (c==2) {
		   System.out.println("Choose type of call:\n1. Calls made from 6:00 a.m. to 6:00 p.m.\n2. Calls made from 6:00 p.m. to 6:00 a.m.");
		   int c2=in.nextInt();
		   
		   int minutes;
		   int min;
		   System.out.println("Enter number of minutes:");
		   minutes=in.nextInt();
		   if (c2==1){
		       
		       if (minutes>75){
		        min=minutes-75;
		        premium_price=premium_price+(min*0.10);
		    }
		   }
		   else if (c2==2){
		       if (minutes>100){
		        min=minutes-100;
		        premium_price=premium_price+(min*0.05);
		    }
		   } 
		   System.out.println("Bill: "+premium_price);
		}
		
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS