EBK JAVA PROGRAMMING
9th Edition
ISBN: 9781337671385
Author: FARRELL
Publisher: CENGAGE LEARNING - CONSIGNMENT
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
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...
Expert Solution & Answer
Trending nowThis is a popular solution!
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.
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…
Chapter 2 Solutions
EBK JAVA PROGRAMMING
Ch. 2 - Prob. 1RQCh. 2 - Prob. 2RQCh. 2 - Prob. 3RQCh. 2 - Prob. 4RQCh. 2 - Prob. 5RQCh. 2 - Prob. 6RQCh. 2 - Prob. 7RQCh. 2 - Prob. 8RQCh. 2 - Prob. 9RQCh. 2 - Prob. 10RQ
Ch. 2 - Prob. 11RQCh. 2 - Prob. 12RQCh. 2 - Prob. 13RQCh. 2 - Prob. 14RQCh. 2 - Prob. 15RQCh. 2 - Prob. 16RQCh. 2 - Prob. 17RQCh. 2 - Prob. 18RQCh. 2 - Prob. 19RQCh. 2 - Prob. 20RQCh. 2 - Prob. 1PECh. 2 - Prob. 2PECh. 2 - Prob. 4PECh. 2 - Prob. 5PECh. 2 - Prob. 6PECh. 2 - Prob. 7PECh. 2 - Prob. 8PECh. 2 - Prob. 9PECh. 2 - Prob. 10PECh. 2 - Prob. 11PECh. 2 - Prob. 12PECh. 2 - Prob. 13PECh. 2 - Prob. 14PECh. 2 - Prob. 15PECh. 2 - Prob. 16PECh. 2 - Prob. 1GZCh. 2 - Prob. 3GZCh. 2 - Prob. 1CPCh. 2 - Prob. 2CP
Knowledge Booster
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
- kindly change the program following the procedure on the problem. please list the changes you have made on the program t..thank youarrow_forwardI am stuck on this problem- this is the question: Meadowdale Dairy Farm sells organic brown eggs to local customers. It charges $3.25 for a dozen eggs, or 45 cents for individual eggs that are not part of a dozen. Write a program that prompts a user for the number of eggs in the order and then display the amount owed with a full explanation using the following wording: You ordered 27 eggs. That’s 2 dozen at $3.25 per dozen and 3 loose eggs at 45 cents each for a total of $7.85.arrow_forwardThe Research team led by Bernadette Wolowitz at Cal-tech University has discovered a new Amoeba that grows in the order of a Fibonacci series every month. They are exhibiting this amoeba in a national. conference. They want to know the size of the amoeba at a particular time instant. If a particular month's index is given, write a program to display the amoeba's size. For Example, the size of the amoeba on month 1, 2, 3, 4, 5, 6,... will be 0, 1, 1, 2, 3, 5, 8.... respectively.arrow_forward
- C++ In this task, you are required to write a code that converts an Octal number into its equivalent Decimal value or vice versa. The user first selects the conversion choice by inserting 1 or 2. Choice 1 is followed by inserting an Octal integer and getting its Decimal equivalent value as an output. Choice 2 requires inserting a Decimal integer and prints out its Octal equivalent. The Octal numeral system, is the base-8 number system, and uses the digits 0 to 7, that is to say 10 octal represents 8 Decimal and 100 octal represents 64 Decimal. Convertion from an Octal integer into Decimal In the Decimal system, each number is the digit multiplied by 10 to the power of its location (starting from 0). For example: 74 decimal = 7 x 10^1 + 4 x 10^0 1252 decimal = 1 x 10^3 + 2 x 10^2 + 5 x 10^1 + 2 x 10^0 each number is the digit multiplied by 8 to the power of its location (starting from 0). For example: 112 octal = 1 x 8^2 + 1 x 8^1 + 2 x 8^0 Converting an Octal integer into…arrow_forwardThis program should compound interest continuously. It asks the user for the number of times they want to see their $1 compounded. And the years used in the equation are 1,2,4,8,16.2^N. I. E. I want to see it compounded three times so the user enters 3. The problem is that when I run it. It computes it as though it's going through numbers like 1,2,3,4,5,6,7,8,9. But I need it to go through the numbers I have it. As in 1,2,4,8,16..2^N And the out put should read [2.0,2.25,2.44140625 HWOS.py-CAsers/kr Help 205 py (3.7A) File Edit Format Run Options Window .Evan Mar th 14 September 2019 Hamework 2 QS print (*Nodel Compound Interest Produ ct= (1 N - int (input{'Enter N: n -[1,2,4,8,116,20] tor a in range (2, N+1) : for 2, 2, 4. D , 16 .. 2-N Periods.) for 3 in range ( len (n>.. - 2 (1+1/1) Droduct.appernd (amount) amount Print (product) ...arrow_forwardHi, I need help with the following assignment. Implement a program that reads in a year and outputs the approximate value of a Ferrari 250 GTO in that year. Use the following table that describes the estimated value of a GTO at different times since 1962. Year Value 1962-1964 $18,500 1965-1968 $6,000 1969-1971 $12,000 1972-1975 $48,000 1976-1980 $200,000 1981-1985 $650,000 1986-2012 $35,000,000 2013-2014 $52,000,000arrow_forward
- A business that uses functions to calculate the weekly payment amounts of employees in a workplace.you are asked to write a program.The weekly payment amount of an employee depends on the following variables:- Number of hours worked - (minimum: 0, maximum: 60)- Hourly wage - (minimum: 0.00 TL, maximum: 30.00 TL)- Number of exemptions - (minimum: 0, maximum: 5)Using these 3 values,- Gross payment amount- General income taxLocal income tax- Social security amount- Net payment amountwill be calculated. →The maximum number of hours an employee can work before earning overtime pay is 40 hour. If the number of hours worked is less than or equal to 40, the gross payment amount will be equals the product of the wage. If the number of hours worked is more than 40, the gross payment amount is 40 times the hourly wage. plus 1.5 times the hourly rate for every hour over 40 →The general withholding tax is 55.77 TL for the weekly payment period. The employee is subject to general taxation the gross…arrow_forwardC++ One way to create a pseudo-random three digit number (and we are including one- and two-digit numbers as well) is rand()%1000. That gives numbers from 000 to 999, which is just what we want. Write a program that generates a random number and asks the user to guess what the number is. If the user's guess is too high then the program should display "Too high, try again." If the user's guess is lower than the random number the program should say "Too low, try again." The program should use a loop that repeats until the user correctly guesses the random number. The program should keep track of the number of guesses the user makes. When the user correctly guesses the random number, the program should display the number of guesses. As specified, have the program tell the player how many guesses were used. A good player should always be able to find a three-digit number in ten or fewer guesses. The programs needs to include a menu that allows the user to select easy (3 digit number),…arrow_forwardf. A laborant in a laboratory does a number of antigen tests in one day. Write a program that simulates the number of antigen tests done in a day in a laboratory, displays the number of positives and negatives, and calculates the % of positives in one day. Your program needs to first generate a random number that will show the number of tests done in a day. One laboratory in a day cannot do more than 100 tests and less than 1 (they do at least one). Then for each of the tests, your program needs to generate a random number to show whether they are positive or negative. In order to write this program, you need to have the following three functions used by the main function: test result (void): This function generates a test result. It should randomly return either one or zero. 1 means positive test result and 0 means negative test result. float positive percentage (int,int) : This function takes the total number of positives and the total number of tests and returns the % of positives.…arrow_forward
- Write a program in c that calculates the student grades’ average for a semester for the number of courses taken in that semester. Your program should do the following: Read from user the number of courses (n) Then, read the courses’ grades for n times (Hint: use a loop) If a grade is grater than 100 or less than 0, ask the user to enter the grade again. Calculate the average of grades using the following formula: average = (sum of grades) / n Print out the average grade on the screen. Note: Always use appropriate data types.arrow_forwardWrite a program that take 5 digit number as an input from the user and perform the following tasks:1. Split a number into digits.2. Find the sum of the all the digits in the number.3. Find the product of the all the digits in the number.4. Find maximum number with in the number along with position.5. Printing the digits in the reverse order.Note: Make user defined functions to perform each task.arrow_forward3) Suppose an airline company has hired you to write a program for choosing the passengers who should leave an overbooked flight. That means the airline has booked too many passengers hoping some of them would not show up on time, but passengers are on board and the aircraft doesn't have enough seats available for all these passengers. Your program chooses the passenger who must leave the flight. Passengers will be ranked based on the fare they have paid for booking (a double number called fare), and their number of loyalty points (an integer number called points). Fare and points are equally important, that means, in order to decide the position of each passenger in the list, fare and points each have 50% importance. A Person with minimum priority (combination of fare and points) will leave the flight. You need to define a class called Passenger with these member variables: passenger's name • fare points. Passenger class must have 3 accessors, 3 mutators, a constructor with three…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
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