Java Programming (MindTap Course List)
Java Programming (MindTap Course List)
9th Edition
ISBN: 9781337397070
Author: Joyce Farrell
Publisher: Cengage Learning
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
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.
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]…
Problem 7: Guess the price of the car!? You will implement a variant of the number guessing game we played in lecture. In this variant, you will ask the user to guess the price of a $42,500 car. Let's assume that the player knows the price of the car is rounded to the nearest $500. If a player's guess is not exactly correct, your program will tell them they are either too high or too low. The player will get as many guesses as they need to guess the price of the $42,500 car. However they will only win the game if they used 5 or fewer guesses. Here are two examples of how the program should work for both cases: Guess the price and win the prize! Enter your guess:50000 Too high! Enter your guess:40000 Too low! Enter your guess:45000 Too high! Enter your guess:42500 You won the car! Guess the price and win the prize! Enter your guess:46000 Too high! Enter your guess:45000 Too high! Enter your guess:44000 Too high! Enter your guess:43000 Too high! Enter your guess:42000 Too low! Enter your…
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