Absolute Java (6th Edition)
6th Edition
ISBN: 9780134041674
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 1, Problem 7PP
Write a
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write a program that computes the theoretical flame temperature when a mixture of
methane, propane, n-butane, and n-pentane (0% to 100% mole methane in 5 %
increments; 0 to 100 mol% propane in 5% increments; 0% to 100% mole n-butane in 5
% increments) at 25°C is burned with excess air (0% to 100% excess in 5% increments)
preheated to preheated to (50°C to 200°C in 10°C increments)
Write a program that simulates the rolling of two dice. The program should use rand to roll the first dice and should use rand again to roll the second dice. The sum of the two values should then be calculated. Note: Since each dice can show an integer value from 1 to 6, then the sum of the to values will vary from 2 to 12, with 7 being the most frequent sum and 2 and 12 being the least frequent sums. Below shows the 36 possible combinations of the two dice. Your program should roll the two dice 36,000 times. Use a single-subscripted array to tally the numbers of times each possible sum appears. Print the results in a tabular format. Also, determine if the totals reasonable (i.e. there are six ways to roll a 7, so approximately one sixth of all the rolls should be 7).
Write a program that asks you to input an integer. After you input the integer, it should ask if you want to input another integer. If you answer y, it should allow you to input a second integer and then output the sum of the two integers you
entered. If you answer n or some character other than y, it should output the integer you input before.
For example:
if you input 4, answer y and then input 3, it should output 7
if you input 4 and answer n, it should output 4
Chapter 1 Solutions
Absolute Java (6th Edition)
Ch. 1 - If the following statement were used in a Java...Ch. 1 - Give a statement or statements that can be used in...Ch. 1 - Write a complete Java program that uses to output...Ch. 1 - What is a compiler?Ch. 1 - What is a source program?Ch. 1 - What is an object program?Ch. 1 - What do you call a program that runs Java...Ch. 1 - Suppose you define a class named NiceClass in a...Ch. 1 - Prob. 9STECh. 1 - Prob. 10STE
Ch. 1 - Can a Java program have two different variables...Ch. 1 - Give the declaration for two variables called feet...Ch. 1 - Give the declaration for two variables called...Ch. 1 - Prob. 14STECh. 1 - Prob. 15STECh. 1 - Prob. 16STECh. 1 - Convert each of the following mathematical...Ch. 1 - What is the output of the following program...Ch. 1 - What is the output produced by the following lines...Ch. 1 - Prob. 20STECh. 1 - Given the following fragment that purports to...Ch. 1 - What is the output produced by the following lines...Ch. 1 - What is the output produced by the following lines...Ch. 1 - What is the output produced by the following?
Ch. 1 - What is the output produced by the following?...Ch. 1 - What is the output produced by the following?...Ch. 1 - What is the output produced by the following?
Ch. 1 - Prob. 28STECh. 1 - Prob. 29STECh. 1 - What is the output of the following two lines of...Ch. 1 - Suppose sam is an object of a class named Person...Ch. 1 - The following code is supposed to output the...Ch. 1 - Prob. 33STECh. 1 - What is the output produced by the following Java...Ch. 1 - What is the normal spelling convention for named...Ch. 1 - Write a line of Java code that will give the name...Ch. 1 - Body Mass Index (BMI) helps in specifying the...Ch. 1 - The video game machines at your local arcade...Ch. 1 - Write a program that starts with the string...Ch. 1 - A government research lab has concluded that an...Ch. 1 - Write a program that starts with a line of text...Ch. 1 - Write a program for calculating the simple...Ch. 1 - Write a program that outputs the number of hours,...Ch. 1 - The following program will compile and run, but it...Ch. 1 - A simple rule to estimate your ideal body weight...Ch. 1 - Scientists estimate that roughly 10 grams of...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Translate the following instructions from English into Vole. a. LOAD register 0x6 with the value 0x77. b. LOAD ...
Computer Science: An Overview (12th Edition)
What do the Ada and COBOL languages have in common?
Concepts of Programming Languages (11th Edition)
Define each of the following terms: supertype subtype specialization entity cluster completeness constraint enh...
Modern Database Management (12th Edition)
(Modified Compound-Interest Program) Modify the application in Fig. 5.6 to use only integers to calculate the c...
Java How To Program (Early Objects)
(Multiples of 2 with an Infinite Loop) Write a program that keeps printing the multiples of the integer 2, name...
C How to Program (8th 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
- Hi, 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_forwardWrite a program that computes the earnings per shift for a babysitter. A babysitter charges $10 per hour before noon and $15 after noon. The program reads the starting time in hours and minutes and the ending time in hours and minutes. All times are between 8:00 am, and 7:59 pm, using a 12-hour clock. For example, you should consider hour 8 as 8 am and hour 6 as 6pm. The program should check the validity of the inputs as follows. 1) Hours are from 0-11 (0 for noon). 2) Minutes are from 0-59. 3) The start time must be before noon. 4) The end time must not be before 1pm. The program should display specific warnings regarding the above when the user submits invalid input; the program should prompt the user to re-enter the times again. The program should output the total hours worked and the total earnings per shift. Example: >9h 20m to 6h 15m You have worked 8 hours and 55 minutes in this shift, earning $120.417 Important Notes: Please do this in C++ Programming Do not use any…arrow_forwardWrite a program that takes a positive integer as the height of the triangle and prints an alphabetical triangle, using lowercase English letters as shown below. Each subsequent row of the triangle should increase in length by two letters. Make sure your program validates the user input. If the user does not input a positive integer, print "Invalid input."arrow_forward
- Write a computer program for calculating carburization heat treatments. The program should ask the user to provide an input for the carbon concentration at the surface (cs), and the concentration of carbon in the bulk (c0).arrow_forwardWrite a program that takes in an integer in the range 11-100 as input. The output is a countdown starting from the integer, and stopping when both output digits are identical. Ex: If the input is: 93 the output is: 93 92 91 90 89 88 Ex: If the input is: 11 the output is: 11 Ex: If the input is: 9 or any value not between 11 and 100 (inclusive), the output is: Input must be 11-100 this is what i have n = int(input())if n > 100 or n < 11:print('Input must be 11-100')exit(0)while True:print(n, end=" ")first_digit = n // 10second_digit = n % 10 if first_digit == second_digit:break n = n-1 my output is 93 92 91 90 89 88 but it needs to be 93 92 91 90 89 88arrow_forwardWrite a program that simulates the rolling of two dice. The program should use rand to roll the first die and should use rand again to roll the second die. The sum of the two values should then be calculated. [Note: Each die can show an integer value from 1 to 6, so the sum of the two values will vary from 2 to 12, with 7 being the most frequent sum and 2 and 12 being the least frequent sums.] Figure 7.32 shows the 36 possible combinations of the two dice. Your program should roll the two dice 36,000 times. Use a one-dimensional array to tally the numbers of times each possible sum appears. Print the results in a tabular format. Also, determine if the totals are reasonable (i.e., there are six ways to roll a 7, so approximately one-sixth of all the rolls should be 7).arrow_forward
- Write a program that determines the distance to a lightning strike based onthe time elapsed between the flash and the sound of thunder. The speedof sound is approximately 1100 ft/ sec and 1 mile is 5280 ft.arrow_forwardYou are to create a program consisting of only the following lines of code. You may put these lines of code in any order, and can re-use the lines as frequently as you wish to. There will be more than one way to achieve the result – try to see if you can obtain the output using fewer lines of code.x = 1y = 10z = 0x = yx += 1y += xy *= xz += xz += yprint(z)The last line of your program print(z) should print out each of the following results, when run:131128123100000000000000000000000000000000 [Note: that’s 1032]4321arrow_forwardWrite a program that takes a bank account balance and an interest rate as an input. And then outputs the value of the account in 5 years. The output should show the value of the account for two different methods of compounding interest: annually and monthly. When compounded annually, the interest is added once per year at the end of the year. When compounded monthly the interest is added in 12 times per year. On annual interest, you can assume that the interest is posted exactly one year from the date of deposit. In other words, you do not have to worry about interest being posted on a specific day of the year, like December 31. Similarly, you can assume monthly interest is posted exactly one month after. Since the account earns interest on the interest, the account should have a higher balance when interest is posted more frequently. Be sure to adjust the interest rate for the time period of the interest. If the rate is 5%, then when posting monthly interest, you use (5/12%). Do your…arrow_forward
- Write a program that takes a bank account balance and an interest rate as an input. And then outputs the value of the account in 5 years. The output should show the value of the account for two different methods of compounding interest: annually and monthly. When compounded annually, the interest is added once per year at the end of the year. When compounded monthly the interest is added in 12 times per year. On annual interest, you can assume that the interest is posted exactly one year from the date of deposit. In other words, you do not have to worry about interest being posted on a specific day of the year, like December 31. Similarly, you can assume monthly interest is posted exactly one month after. Since the account earns interest on the interest, the account should have a higher balance when interest is posted more frequently. Be sure to adjust the interest rate for the time period of the interest. If the rate is 5%, then when posting monthly interest, you use (5/12%). Do your…arrow_forwardWrite a program that takes in an integer in the range 11-100 as input. The output is a countdown starting from the integer, and stopping when both output digits are identical. Ex: If the input is: 93 the output is: 93 92 91 90 89 88 Ex: If the input is: 11 the output is: 11 Ex: If the input is: 9 or any value not between 11 and 100 (inclusive), the output is: Input must be 11-100arrow_forwardWrite a program that simulates flipping a coin to make decisions. The input is how many decisions are needed, and the output is either heads or tails. Assume the input is a value greater than 0. Ex: If the input is: 3 the output is: heads tails heads For reproducibility needed for auto-grading, seed the program with a value of 2. In a real program, you would seed with the current time. In that case, every program's output would be different, which is what is desired but can't be auto-graded. Note: A common student mistake is to call srand() before each call to rand(). But seeding should only be done once, at the start of the program, after which rand() can be called any number of times. Your program must define and call the following function that returns "heads" or "tails".string HeadsOrTails() #include <iostream>#include <cstdlib>using namespace std; /* Define your function here */ int main() {// Add more variables as neededsrand(2); // Unique seed /* Type your code here…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