write a program that calculates a customer's monthly bill. it should input customer name, which package the customer has purchased, and how many hours were used. it should then create a bill that includes the input informtion and the total amount due. the bill should be written to a file.

in C++

5 answers

What have you done so far?
i dnt have anything. im totally lost
We can help you review what you have done, in terms of programming problems, pseudocodes, debugging, etc.

You must have gone through a good part of the course, and it is time to apply what you have learned.

Post what you can do or have done and get the project started.
import java.util.Scanner;
import java.text.DecimalFormat;
public class Bill{
public static void main(String[] args){
String input;
char servicePackage;
int hours=0;
int extrahours=0;
double charges=0.0;
int totalHours = 0;
final double BASE_RATE_A = 9.95;
final double BASE_RATE_B = 13.95;
final double BASE_RATE_C = 19.95;
final int BASE_HOUR_A = 10;
final int BASE_HOUR_B = 20;
final double PER_HOUR_A = 2.00;
final double PER_HOUR_B = 1.00;

Scanner kb = new Scanner(System.in);
DecimalFormat fmt = new DecimalFormat("$##.00");

System.out.print("Service package (A, B, or C): ");
input = kb.nextLine();
servicePackage = input.charAt(0);

if(servicePackage == 'A'){
System.out.print("Number of hours: ");
hours = kb.nextInt();
if(hours<=10){
charges = BASE_RATE_A;
System.out.println("Total Charges: "+fmt.format(charges));
}
else{
extrahours=hours-BASE_HOUR_A;
charges = BASE_RATE_A +(extrahours*PER_HOUR_A);
System.out.println("Total Charges: "+fmt.format(charges));
}
}
else if(servicePackage == 'B'){
System.out.print("Number of hours: ");
hours = kb.nextInt();
if(hours<=20){
charges = BASE_RATE_B;
System.out.println("Total Charges: "+fmt.format(charges));
}
else{
extrahours=hours-BASE_HOUR_B;
charges = BASE_RATE_B+(extrahours*PER_HOUR_B);
System.out.println("Total Charges: "+fmt.format(charges));
}

}
else if(servicePackage == 'C'){
System.out.print("Number of hours: ");
hours = kb.nextInt();
charges = BASE_RATE_C;
System.out.println("Total Charges: "+fmt.format(charges));
}

}
}
Good work!

Usually customer like to know how the charges are broken down into fixed charges, rate, and number of hours, similar to your electricity bill. So you should include the input information as requested by the question.

You'll still need to write the bill to a file.