What would it mean when I see : (/* phone bill_1[..]) this with two little dots afterward? I can upload the file or email the java file if needed? this is not something I wrote but something that was given to me in an assignment by my instructor. Also, how do I start my code in the right place? sorry for bad formatting. :/
{START OF CODE} {
/* phone bill_1
uses toUpperCase with strings
* */
import java.util.*;
public class PhoneBill_1 {
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
int minutes;
double base, extra, due;
String plan;
int countA = 0, countB = 0, totMinutes = 0;;
double total = 0.0;
System.out.print("Enter your plan (A or B): ");
plan = keyboard.next().toUpperCase();
while(plan.charAt(0) != 'Q'){
System.out.print("Enter the minutes talked: ");
minutes = keyboard.nextInt();
if (plan.charAt(0) == 'A'){
base = 25;
if (minutes > 50){
extra = (minutes - 50) * 0.10;
}
else{
extra = 0.0;
}
countA++;
}
else{
base = 35;
if (minutes > 100){
extra = (minutes - 100) * 0.05;
}
else{
extra = 0.0;
}
countB++;
}
due = base + extra;
System.out.printf("\nBase cost: $%2.2f\n",base);
System.out.printf("Extra minutes charge: $%2.2f\n",extra);
System.out.printf("Total: $%2.2f\n",due);
total += due;
totMinutes += minutes;
System.out.print("Enter your plan (A or B, q to quit): ");
plan = keyboard.next();
}
// summary data
System.out.println("\n\nSummary Data\n*****************\n\n");
System.out.println("# of customers: " + (countA + countB) );
System.out.println("\t# of customers in Plan A: " + countA);
System.out.println("\t# of customers in Plan B: " + countB);
System.out.printf("Total collected: $%2.2f\n" , total);
System.out.printf("Total minutes: " + totMinutes);
keyboard.close();
}
}
Aucun commentaire:
Enregistrer un commentaire