EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
9th Edition
ISBN: 9781337671385
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
The local taqueria wants you to write a program that tracks the number of burritos they sell and helps them analyze their business.  There are four types of burritos: carnitas, beef, shrimp, and vegetarian.  Your program should prompt the user for the number of burritos sold of each type, and then print out a report listing a total number of burritos sold, and the type of burrito which sold the most. You must use two parallel 4-element arrays; one array of type string to store the names of the burrito types, and one array of type int to store the number of burritos sold per type.  You can store the name of the burrito types using an initialization list.  To get you started, here are the array declarations: **************************************************************** const int NUM_TYPES = 4;string burritoType[NUM_TYPES] = {"carnitas", "beef", "shrimp", "veggie"};int numSold[NUM_TYPES]; **************************************************************** So, for example, burritoType[1]…
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