Let\'s say a customer purchased an Internet service provider. Thepackage costs f
ID: 3613566 • Letter: L
Question
Let's say a customer purchased an Internet service provider. Thepackage costs for $9.95 per month 10 hours of access are provided.Additional hours are $2.00 per hour.How would you write the program to display the customer's monthlybill if the customer pays the money for the package? How would youwrite the program to display the customer's monthly bill if thecustomer pays money for the additional hours?
I have no idea how to write $2.00 per hour for additional hours. Iknow that I don't just use addition.
Thank you!
I really appreciate your help.
If you do not understand what I said, please let me know.
Explanation / Answer
For each additional hour, the customer must pay$2.00. publicstatic double getMonthlyBill(int numHours) { double output= 9.95; if(numHours>10) { output+=(numHours-10)*2; } returnoutput; } Suppose a customer wants 3 additional hours. System.out.println(getMonthlyBill(13)); Now, you could make a main method to test yourcode. public staticvoid main(String[] args) { // keyboardinput Scanner kb= newScanner(System.in); // prompt forinput System.out.print("Enter thenumber hours:: "); int numHours= kb.nextInt(); System.out.println(); // performcalculations double cost= getMonthlyBill(numHours); // print cost System.out.println("Yourmonthly bill is $"+String.format("%.2f",cost)); }
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.