Big Java Late Objects
2nd Edition
ISBN: 9781119330455
Author: Horstmann
Publisher: WILEY
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 2, Problem 10PE
Write a
- The cost of a new car
- The estimated miles driven per year
- The estimated gas price
- The efficiency in miles per gallon
- The estimated resale value after 5 years
Compute the total cost of owning the car for five years. (For simplicity, we will not take the cost of financing into account.) Obtain realistic prices for a new and used hybrid and a comparable car from the Web. Run your program twice, using today’s gas price and 15,000 miles per year. Include pseudocode and the program runs with your assignment.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
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…
Write a program to simulate a bank transaction. As the banker, create a single pin number for all customer that enter the bank (a constant variable). You are now ready for customer transactions. Prompt the customer for their name and pin number. If the pin number does not match your banker pin number, then they are not a valid customer. Send them away.
If the customer is a valid customer, there are two bank accounts: checking and savings. First, ask for the initial balances of the bank accounts; reject negative balances. Then ask for the transactions; options are deposit, withdrawal, and transfer. Then ask for the account; options are checking and savings. Then ask for the amount; reject transactions that overdraw an account. At the end, display the balances of both accounts (using printf) to two decimal places and with a leading dollar sign.
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
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
Type in and run the program presented in this chapter. Check the programs results by comparing the original fil...
Programming in C
(Modified Compound-Interest Program) Modify the compound-interest application of Fig. 5.6 to repeat its steps f...
Java How To Program (Early Objects)
3.12 (Date Create a class called Date that includes three pieces Of information as data
members—a month (type ...
C++ How to Program (10th Edition)
Shipping Charges The Fast Freight Shipping Company charges the following rates: Weight of Package (in Kilograms...
Starting Out with C++ from Control Structures to Objects (9th Edition)
In the following exercises, write a program to carry out the task. The program should use variables for each of...
Introduction to Programming Using Visual Basic (10th Edition)
An inverter performs an operation known as complementation assertion inversion both answers (a) and (c)
Digital Fundamentals (11th 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
- Write a program using Python to solve the locker riddle which reads as follows: Imagine 100 lockers numbered 1 to 100 with 100 students lined up in front of those 100lockers:The first student opens every locker.The second student closes every 2nd locker.The 3rd student changes every 3rd locker; if it’s closed, she opens it; if it’s open, she closes it.The 4th student changes every fourth locker (e.g., 4th, 8th, etc.).The 5th student changes every 5th locker (e.g., 5th, 10th, etc.).That same pattern continues for all 100 students. Which lockers are left open after all 100 students have walked the rowof lockers?arrow_forwardsolve using paython language and take screenshot contains the codearrow_forwardSuppose you have a knapsack that can carry up to 17 pounds. You can only put certain items, and each item has a weight and a value. You want to put the items that will give you the highest possible value, but you can only carry up to 15 pounds. Here are the items you can put and their weights and values: I Weight value Value/Weight 1 2 10 5 2 4 30 7.5 3 6 50 8.33 4 9 70 7.78 5 10 80 8 Table 1: Caption Your task is to solve the Knapsack Problem using a greedy approach.Hints:- Sort the items by their value-to-weight ratio in descending order. Start with the item with the highest value-to-weight ratio and add it to the knapsack. - Continue adding items to the knapsack in descending order of their value-to-weight ratio until the knapsack is full or there are no more items left. - Your solution should output the total value of the items in the knapsack and the list of items that you have put. -This…arrow_forward
- Given a list of scores and a passing score, you are asked to find out the average score and the number of scores which are equal to or higher than the passing score. For examples, the list of scores is as follows: 46, 58, 56, 59, 89, 93, 77, 98, 100, 64 If the passing score is 60, then the answers should be 74 and 6. If the passing score is 55, then the answers should be 74 and 9. Implement the above task using MIPS in QtSpim. Initialize the array of scores in memory using any integer values between 0 and 100. The passing score should be obtained from user’s input and the answer must be printed out. See the following screen snapshot for reference.arrow_forwardModify the script RollDie.py that we provided with this chapter’s examples to simulate rolling two dice. Calculate the sum of the two values. Each die has a value from 1 to 6, so the sum of the values will vary from 2 to 12, with 7 being the most frequent sum, and 2 and 12 the least frequent. The following diagram shows the 36 equally likely possible combinations of the two dice and their corresponding sums: If you roll the dice 36,000 times: • The values 2 and 12 each occur 1/36th (2.778%) of the time, so you should expect about 1000 of each. • The values 3 and 11 each occur 2/36ths (5.556%) of the time, so you should expect about 2000 of each, and so on. Use a command-line argument to obtain the number of rolls. Display a bar plot summarizing the roll frequencies. The following screen captures show the final bar plots for sample executions of 360, 36,000 and 36,000,000 rolls. Use the Seaborn barplot function’s optional orient keyword argument to specify a horizontal bar plot.…arrow_forwardTask 03: Read the concept of Binomial coefficient given in chapter-6. Write a method that takes two parameters n and k and returns the value of Binomial Coefficient C(n, k). For example, your function should return 20 for n = 6 and k = 3, and it should return 35 for n= 7 and k = 4. ( confirm it through the Pascal's triangle as given below). 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 15 10 10 5 1 15 (20) 15 6 1 1 7 21 35 (35 21 7 1 1arrow_forward
- Welcome to the era of Aladdin and the great magic lamp. This is 1st of January and Aladdin will be in jail for one year. He was recently caught for helping forty thieves. Now he has nothing to do. But he knows that Jasmine is waiting for him. At some point he got an idea to give Jasmine a magical program that can find intervals of months from a year. This allows her to easily determine how long it will take for Aladdin to get out. Then Aladdin rubs the magic lamp and The Genie appears. Then he asked The Genie to make such a magical program. Unfortunately the Genie doesn't know programming and he wants your help to create that magical program. Genie will give you N as the day of the year and you have to print in which month that day is. Input Format Input will contain one line with a single integer N, day of the year. Constraints 1 <= N <= 365 Output Format Print a single line containing the name of month. Be careful about the newline ('\n') at the end. Sample Input 0 1 Sample…arrow_forwardCorrect answer will be upvoted else downvoted. Computer science. You are given a positive integer x. Check whether the number x is representable as the amount of the solid shapes of two positive integers. Officially, you really want to check in case there are two integers an and b (1≤a,b) to such an extent that a3+b3=x. For instance, in the event that x=35, the numbers a=2 and b=3 are reasonable (23+33=8+27=35). In the event that x=4, no pair of numbers an and b is reasonable. Input The primary line contains one integer t (1≤t≤100) — the number of experiments. Then, at that point, t experiments follow. Each experiment contains one integer x (1≤x≤1012). Kindly note, that the input for some experiments will not squeeze into 32-cycle integer type, so you should use something like 64-bit integer type in your programming language. Output For each experiment, output on a different line: "Indeed" in case x is representable as the amount of the 3D shapes of two…arrow_forwardU is upward, D is downward, L is left and R is right : Using the methods pickDir() and exractInt() as shown below, to write a simple automated game: how long does it take a robot to travel from a left line of a field to the right line? Assume field is 15 units apart (meters, kilometers, it doesn’t matter), and the robot starts on the left line. pickDir(): // return string with random direction and random distance (within maxDist) public static String pickDir (int maxDist) { Random r = new Random(); // random number generator // return direction + distance return ( "" + "LRUD".charAt( r.nextInt(4) ) + (r.nextInt(maxDist) + 1) ); } extractInt(): // returns integer from string, from pos p1 to p2: str = "D1" – extractInt(str,1,1); public static int extractInt (String str, int p1, int p2) { return ( Integer.parseInt( str.substring(p1, p2+1) ) ); } Write the main() method that keeps looping until the robot’s random left…arrow_forward
- java - NetBeansarrow_forwardIn business applications, youare often asked to compute the mean and standard deviation of data. The mean issimply the average of the numbers. The standard deviation is a statistic that tellsyou how tightly all the various data are clustered around the mean in a set of data.For example, what is the average age of the students in a class? How close are theages? If all the students are the same age, the deviation is 0.Write a program that prompts the user to enter 10 numbers and displays the meanand standard deviations of these numbers using the following formula:arrow_forwardThe Monty Hall game is a statistical problem: there is a TV show (like the Monty Hall show) that allows contestants to choose between three doors, A, B, and C. Behind one of these doors is a new car (the winning door), and behind the other two are goats (the losing doors). After the contestant makes a choice, the game show host shows a goat behind one of the doors NOT chosen. The contestant is then given a choice to either switch to the other, non-opened door, or stick with their original guess. The interesting part of this “game" is the statistics involved –a person has a 1/3 chance of originally picking a winning door. The other door – that which is not revealed to have a goat but also was not originally chosen – actually has a 2/3 chance of being a winning door. Therefore, it is in the contestant's best interest to switch doors. You will create a program that simulates the Monty Hall game, where the computer plays the role of the host. The program must have no outputs, but 1) Ask…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
Constants, Variables, Data types, Keywords in C Programming Language Tutorial; Author: LearningLad;https://www.youtube.com/watch?v=d7tdL-ZEWdE;License: Standard YouTube License, CC-BY