Absolute Java (6th Edition)
Absolute Java (6th Edition)
6th Edition
ISBN: 9780134041674
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
bartleby

Concept explainers

bartleby

Videos

Textbook Question
Book Icon
Chapter 2, Problem 14PP

From Programming Project 10 in Chapter 1, scientists estimate that roughly 10 grams of caffeine consumed at one time is a lethal overdose. Write two programs to compute how many drinks it takes to kill a person.

The first program should input the name of the drink and the number of milligrams of caffeine in the drink. It should then output the drink name and the number of drinks it takes to kill a person. For example, if the user enters "coffee" and "160", then the program should output "It will take approximately 62.5 drinks of coffee to kill a person from caffeine."

The second program should perform the same calculation as the first program, but read the name of the drink and the number of milligrams of caffeine in the drink from a file named drink. txt and output the answer to the console.

Blurred answer
Students have asked these similar questions
Write a program with total change amount (in cents) as an integer input, and output the change using the fewest coins, one coin type per line. The coin types are Dollars, Quarters, Dimes, Nickels, and Pennies. Use singular and plural coin names as appropriate, like 1 Penny vs. 2 Pennies. Hint: Start from the largest denomination. Divide the change amount by the number of cents in the denomination to get the number of coins used. The remainder of the division is used to find the number of coins used in the next denomination. Ex: value // 100 gives the number of dollars used. The remainder is divided by 25 to find the number of quarters used. Ex: If the input is: 0 (or less than 0), the output is: No change Ex: If the input is: 45 the output is: 1 Quarter 2 Dimes
Write a program with total change amount as an integer input, and output the change using the fewest coins, one coin type per line. The coin types are Dollars, Quarters, Dimes, Nickels, and Pennies. Use singular and plural coin names as appropriate, like 1 Penny vs. 2 Pennies. Ex: If the input is: 0 (or less than 0), the output is: No change Ex: If the input is: 45 the output is: 1 Quarter 2 Dimes   ''' Type your code here. '''
Write a program that can be used to calculate the federal tax. The tax is calculated as follows: For single people, the standard exemption is $4,000; for married people, the standard exemption is $7,000. A person can also put up to 6% of his or her gross income in a pension plan. The tax rates are as follows: If the taxable income is: Between $0 and $15,000, the tax rate is 15%. Between $15,001 and $40,000, the tax is $2,250 plus 25% of the taxable income over $15,000. Over $40,000, the tax is $8,460 plus 35% of the taxable income over $40,000. Prompt the user to enter the following information: Marital status If the marital status is “married,” ask for the number of children under the age of 14 Gross salary (If the marital status is “married” and both spouses have income, enter the combined salary.) Percentage of gross income contributed to a pension fund Your program must consist of at least the following functions: Function getData: This function asks the user to enter the…

Chapter 2 Solutions

Absolute Java (6th Edition)

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
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
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