EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
8th Edition
ISBN: 9781305480537
Author: FARRELL
Publisher: CENGAGE LEARNING - CONSIGNMENT
bartleby

Videos

Expert Solution & Answer
Book Icon
Chapter 2, Problem 2CP

Explanation of Solution

Program code:

SammsRentalPrice.java

//import the required header files

import java.util.Scanner;

//create a class

public class SammsRentalPrice

{

//define the main() method

public static void main(String[] args)

{

//create an object of Scannr class

Scanner scan = new Scanner(System.in);

//prompt the user to enter the number of minutes

System.out.println("Enter the number of minutes: ");

//scan fo the inpout

int minutes = scan.nextInt();

//calculate the number of hours

int hours = minutes/60;

//set the value of minutes

minutes = minutes%60;

//calculate total cost

int totalCost = hours*40 + minutes;

//print the values

System.out...

Blurred answer
Students have asked these similar questions
A supermarket is doing a sales promotion for soft drinks. If one day you buy soft drinks and bring the empty bottles the next day, they exchange each set of K empty bottles for a full one. A customer wants to make the most of this offer and therefore bought several bottles on the first day of the promotion. Now he wants to know how many bottles he will have at the end of the second day of the promotion if he use it to the fullest. Make a program to calculate this. Input The first input line contains integer T (1 ≤ T ≤ 10000), which indicates the number of test cases. In each of the following T lines come two integers N and K (1 ≤ K, N ≤ 10000), respectively the number of soft drinks bought and the number of empty bottles to gain a full. Output For each test case print the number of bottles that the customer will have on the second day, if he makes the most of the offer.
Write a program that computes and displays the charges for a patient’s hospital stay. First, the program should ask if the patient was admitted as an in-patient or an out-patient. If the patient was an in-patient the following data should be entered: • The number of days spent in the hospital• The daily rate• Charges for hospital services (lab tests, etc.)• Hospital medication charges.If the patient was an out-patient the following data should be entered:• Charges for hospital services (lab tests, etc.)• Hospital medication charges.Use a single, separate function to validate that no input is less than zero. If it is, it should be re-entered before being returned.Once the required data has been input and validated, the program should use two overloaded functions to calculate the total charges. One of the functions should accept arguments for the in-patient data, while the other function accepts arguments for out- patient data. Both functions should return the total charges.
A parking garage charges a $20.00 minimum fee to park for up to three hours. The garage charges an additional $5.00 per hour for each hour or part thereof in excess of three hours. The maximum charge for any given 24- hour period is $50.00. Assume that no car parks for longer than 24 hours at a time. Write a program that calculates and printsthe parking charges for each of three customers who parked their cars in this garage yesterday. You should enter the hours parked for each customer. Your program should print the results in a neat tabular format and should calculate and print the total of yesterday’s receipts. The program should use the function calculateCharges to determine the charge for each customer. Your outputs should appear in the following format:                                                                                         Car                Hours              Charge1                      1.5                  20.002                      4.0…
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Java random numbers; Author: Bro code;https://www.youtube.com/watch?v=VMZLPl16P5c;License: Standard YouTube License, CC-BY