Big Java Late Objects
2nd Edition
ISBN: 9781119330455
Author: Horstmann
Publisher: WILEY
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 2, Problem 6PP
Giving change. Implement a
Display the dollars, quarters, dimes, nickels, and pennies that the customer should receive in return. In order to avoid roundoff errors, the program user should supply both amounts in pennies, for example 274 instead of 2.74.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Using Eclipse:
Implement a program that directs a cashier how to give change. The program has two inputs: the amount due and the amount received from the customer. Display the dollars, quarters, dimes, nickels, and pennies that the customer should receive in return. In order to avoid roundoff errors, the program user should supply both amounts in pennies, for example 274 instead of 2.74.
Use labels for each currency when you display.
Write a program that asks users when their birthday is. Use information provided to give them their astrological sign. Each of the twelve signs should display a different horoscope. Use the following dates for each sign, keeping in mind that both month and day must be evaluated for an accurate result.
Aries: March 21–April 20
Taurus: April 21–May 21
Gemini: May 22–June 21
Cancer: June 22–July 22
Leo: July 23–August 22
Virgo: August 23–September 23
Libra: September 24–October 23
Scorpio: October 24–November 22
Sagittarius: November 23–December 21
Capricorn: December 22–January 20
Aquarius: January 21–February 19
Pisces: February 20–March 20
kindly change the program following the procedure on the problem. please list the changes you have made on the program t..thank you
Chapter 2 Solutions
Big Java Late Objects
Ch. 2.1 - Declare a variable suitable for holding the number...Ch. 2.1 - What is wrong with the following variable...Ch. 2.1 - Declare and initialize two variables, unitPrice...Ch. 2.1 - Prob. 4SCCh. 2.1 - Some drinks are sold in four-packs instead of...Ch. 2.1 - Prob. 6SCCh. 2.1 - Prob. 7SCCh. 2.1 - Prob. 8SCCh. 2.1 - How would you explain assignment using the parking...Ch. 2.2 - A bank account earns interest once per year. In...
Ch. 2.2 - In Java, how do you compute the side length of a...Ch. 2.2 - The volume of a sphere is given by V=43r3 If the...Ch. 2.2 - Prob. 13SCCh. 2.2 - Prob. 14SCCh. 2.3 - Write statements to prompt for and read the users...Ch. 2.3 - What is wrong with the following statement...Ch. 2.3 - Prob. 17SCCh. 2.3 - What is problematic about the following statement...Ch. 2.3 - What is the output of the following statement...Ch. 2.3 - Using the printf method, print the values of the...Ch. 2.4 - Prob. 21SCCh. 2.4 - Suppose the architect specifies a pattern with...Ch. 2.4 - A robot needs to tile a floor with alternating...Ch. 2.4 - For a particular car, repair and maintenance costs...Ch. 2.4 - The shape of a bottle is approximated by two...Ch. 2.5 - What is the length of the string "Java Program"?Ch. 2.5 - Consider this string variable. String str = "Java...Ch. 2.5 - Use string concatenation to turn the string...Ch. 2.5 - Prob. 29SCCh. 2.5 - Prob. 30SCCh. 2 - Write declarations for storing the following...Ch. 2 - What is the value of mystery after this sequence...Ch. 2 - What is wrong with the following sequence of...Ch. 2 - Write the following mathematical expressions in...Ch. 2 - Write the following Java expressions in...Ch. 2 - What are the values of the following expressions?...Ch. 2 - What are the values of the following expressions,...Ch. 2 - What are the values of the following expressions?...Ch. 2 - Assuming that a and b are variables of type int,...Ch. 2 - Suppose direction is an integer angle between 0...Ch. 2 - Find at least five compile-time errors in the...Ch. 2 - Find three run-time errors in the following...Ch. 2 - Consider the following code segment. double...Ch. 2 - Explain the differences between 2, 2.0, 2, 2, and...Ch. 2 - Explain what each of the following program...Ch. 2 - Write pseudocode for a program that reads a word...Ch. 2 - Write pseudocode for a program that reads a name...Ch. 2 - Write pseudocode for a program that computes the...Ch. 2 - Modify the pseudocode for the program in How To...Ch. 2 - Prob. 20RECh. 2 - You are cutting off a piece of pie like this,...Ch. 2 - The following pseudocode describes how to obtain...Ch. 2 - Suppose you are given a string str and two...Ch. 2 - Prob. 24RECh. 2 - For each of the following computations in Java,...Ch. 2 - Prob. 26RECh. 2 - This chapter contains a number of recommendations...Ch. 2 - Write a program that displays the dimensions of a...Ch. 2 - Write a program that computes and displays the...Ch. 2 - Write a program that reads a number and displays...Ch. 2 - Write a program that prompts the user for two...Ch. 2 - Enhance the output of Exercise E2.4 so that the...Ch. 2 - Write a program that prompts the user for a...Ch. 2 - Write a program that prompts the user for a radius...Ch. 2 - Write a program that asks the user for the lengths...Ch. 2 - Improve the program discussed in How To 2.1 to...Ch. 2 - Write a program that helps a person decide whether...Ch. 2 - Write a program that asks the user to input The...Ch. 2 - File names and extensions. Write a program that...Ch. 2 - Write a program that reads a number between 1,000...Ch. 2 - Write a program that reads a number between 1,000...Ch. 2 - Printing a grid. Write a program that prints the...Ch. 2 - Write a program that reads in an integer and...Ch. 2 - Write a program that reads two times in military...Ch. 2 - Writing large letters. A large letter H can be...Ch. 2 - Write a program that transforms numbers 1, 2, 3, ,...Ch. 2 - Write a program that prints a Christmas tree:...Ch. 2 - Easter Sunday is the first Sunday after the first...Ch. 2 - In this project, you will perform calculations...Ch. 2 - The following pseudocode describes how a bookstore...Ch. 2 - The following pseudocode describes how to turn a...Ch. 2 - The following pseudocode describes how to extract...Ch. 2 - Giving change. Implement a program that directs a...Ch. 2 - An online bank wants you to create a program that...Ch. 2 - A video club wants to reward its best members with...Ch. 2 - Consider the following circuit. Write a program...Ch. 2 - The dew point temperature Td can be calculated...Ch. 2 - The pipe clip temperature sensors shown here are...Ch. 2 - Prob. 12PPCh. 2 - Consider the following tuning circuit connected to...Ch. 2 - According to the Coulomb force law, the electric...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Describe a situation when a history-sensitive variable in a subprogram is useful.
Concepts Of Programming Languages
Consider Figure 5.16, the decile-wise lift chart for the transaction data model, applied to new data. a. Interp...
Data Mining for Business Analytics: Concepts, Techniques, and Applications with XLMiner
Write SQL queries to answer the following questions: Which students have an ID number that is less than 50000? ...
Modern Database Management
Consider the adage Never ask a question for which you do not want the answer. a. Is following that adage ethica...
Experiencing MIS
Is it a good idea to make member variables private? Why or why not?
Starting Out with C++ from Control Structures to Objects (9th Edition)
What default value is assigned to each of the following variables? 1. Integer 2. Double 3. Boolean 4. Byte 5. D...
Starting Out With Visual Basic (7th Edition)
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
- 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.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_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
- 4. Write a program which to find the grace marks for a student using switch. The user should enter the class obtained by the student and the number of subjects he has failed in. - If the student gets first class and the number of subjects he failed in is greater than 3, then he does not get any grace. If the number of subjects he failed in is less than or equal to 3 then the grace is of 5 marks per subject. - If the student gets second class and the number of subjects he failed in is greater than 2, then he does not get any grace. If the number of subjects he failed in is less than or equal to 2 then the grace is of 4 marks per subject. - If the student gets third class and the number of subjects he failed in is greater than 1, then he does not get any grace. If the number of subjects he failed in is equal to 1 then the grace is of 5 marks per subject. [Marks - 10]arrow_forwardAn electronic shop wants you to write a program to take orders from the clients and print the invoice. Your program asks for the item, the price per item and the quantity. The shop offers 2 types of delivery. If it is a fast delivery, we add 15$, otherwise we add 10$. Note that the user should enter 'f'or 'F' for fast delivery. Otherwise, the program consider that is a normal delivery (10$). Finally, we have a discount rule to be applied. If the total cost is greater than 100$, the client gets 5% discount Sample run1: Enter the item: TV Enter the price ($): 60 Enter the quantity: 2 Fast delivery (f/F)? f You have ordered 2 Ty with a *fast* Delivery: 15$ Total cost is 135.0$ You got a discount of 135*5%=6.754 After discount you should pay 128.25$ Sample run2: Enter the item: USB Enter the price in $: 10 Enter the quantity: 3 Fast delivery (f/F) ? n You have ordered 3 USB (s) with a delivery: 10$ Total cost is 40$arrow_forwardPython For this lab, you will use a tuple to represent a student record. A student record consists of the student’s name, year, and GPA. For example, (“John”, “Senior”, 3.7) is a record for John who is a senior with a 3.7 GPA. You will write a program that prompts the user for the number of records to enter. Then it reads input from the user for each record. Remember that each record consists of a student’s name, year, and GPA. It then prints the record of each student as shown below. Functions: You will write the following functions: read_records(n) Read n number of records and return a list of records. print_records(records) Takes in a list of records and print each one. main() Prompts the user for the number of records to read, get a list of records from the user, and print the records. Optional: print the average GPA of the students. Sample run: How many students record to enter: 2 Enter student's name: John Enter student's year: junior Enter…arrow_forward
- Make Camel Case. Create a program that reads a multi-word phrase, and prints the Camel Case equivalent. For example, for input “total account balance” the program shall output “totalAccountBalance”.Notice that the first word is in lowercase (even if it contains uppercase letters). The rest of the words, only their initials are capitalized.arrow_forwardWrite a program that picks four cards from a deck of 52 cards and computes their sum. An ace, king, queen, and jack represent 1, 13, 12, and 11, respectively. Your program should display the number of picks that yieldthe sum of 24.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
- Write a program that deals a number of cards (their numerical values) to a player's hand. To begin, the program asks the player for the values of the deck of cards. Then, the program deals the first two cards of the deck to a player's hand, and asks him if he wants another card. If he does not want a card, the program ends. If he wants a card, the program deals the next available card in the deck, adds it to the player's hand, and asks the player if he wants another card. The dealing process repeats as long as the user continues to accept cards, or until the cards in the deck run out. Card dealing involves copying the available card from the deck vector to another vector, which stores the player's hand, at the next available position. Assume that the deck of cards consists of only 10 cards with numerical values from 1 to 10, which the player will enter by keyboard before the program deals. The following functions must be implemented/used: enterDeckValues. - This…arrow_forwardjava - NetBeansarrow_forwardWrite a program that finds word differences between two sentences. The input begins with the first sentence and the following input line is the second sentence. Assume that the two sentences have the same number of words. The program displays word pairs that differ between the two sentences. One pair is displayed per line. Ex: If the input is: Smaller cars get better gas mileage Tiny cars get great fuel economy then the output is: Smaller Tiny better great gas fuel mileage economy Hint: Store each input line into a list of strings.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