Please write a Java program that ask the user how many beers he or she expects to consume each day, on average, as well as the average amount of money he or she spends on a single 12-ounce can of beer. Studies have shown that, on average, someone who consumes a single 12-ounce can of beer every day without compensating for the calorie intake through diet modifications or extra exercise, will gain approximately 15 pounds in one year. You can assume this ratio of beer-to-weight-gain is constant. (For example, doubling the beer consumption to two 12-ounce cans per day will lead to 30 pounds of extra weight in one year.)
Using this information, your goal is to write a program to determine the following:
All output should be displayed using 2 digits of precision after the decimal point!
You may assume that there are 365 days in a year (ignoring leap years).
Output Sample
Here is one sample output of running the program. Note that this test is NOT a comprehensive test. You should test your program with different data than is shown here based on the specifications given. The user input is given in italics while the program output is in bold.
Sample Run #1
On average, how many beers will you consume each day?
2.5
On average, how much will you pay for each can of beer?
1.25
That is approximately 912.50 beers in one year.
In one year, you will consume approximately 136875.00 calories from beer alone.
Without diet or exercise to counter these calories, you can expect to gain 37.50 pounds from drinking that much beer this year.
SOURCE CODE IN JAVA:
import java.util.Scanner; //to use Scanner class for input
class Main
{
public static void main(String[] args)
{
Scanner in=new Scanner(System.in); //Scanner object for input
System.out.print("On average, how many beers will you consume each day? "); //input prompt
double beerPerDay=in.nextDouble(); //input
System.out.print("On average, how much will you pay for each can of beer? "); //input prompt
double costPerbeer=in.nextDouble(); //input
//calculating
double totalBeers=beerPerDay*365;
double totalCost=totalBeers*costPerbeer;
double calories=totalBeers*150;
double weightGained=beerPerDay*15;
//output
System.out.println("That is approximately "+String.format("%.2f",totalBeers)+" beers in one year.");
System.out.println("In one year, you will consume approximately "+String.format("%.2f",calories)+" calories from beer alone.");
System.out.println("Without diet or exercise to counter these calories, you can expect to gain "+String.format("%.2f",weightGained)+" pounds from drinking that much beer this year.");
System.out.println("You will spend $"+String.format("%.2f",totalCost)+" on beer alone in one year.");
}
}
OUTPUT:
Please write a Java program that ask the user how many beers he or she expects...
Problem C: Walking off the Calories Suppose a person can burn off the 150 calories from a beer by walking for 40 minutes at a moderate pace of 3 miles per hour. Based on the number of beers the user consumes each day, as well as the number of minutes he or she walks each day, determine how much longer the user must walk (both in minutes as well as in hours) in one year to counter the rest of...
I need help to write a program in Java. If a moderately active person cuts their calorie intake by 500 calories a day, they can typically lose about 4 pounds a month. Write a program that lets the user enter their starting weight, then creates and displays a table showing what their expected weight will be at the end of each month for the next 6 months if they stay on this diet.
Write a program and flowchart. The program should ask the user how many customers they want to track. Then, it asks for customer numbers, and sales by customer. At the end, it prints out the customer number, the customer sales, and then the total sales and average sales. You must use two different arrays, one for customer number, and one for sales. These are, in effect, parallel arrays. You must use a "while" loop to gather customer number and sales....
The Yukon Widget Company manufactures widgets that weigh 9.2 pounds each. Write a Java program that calculates how many widgets are stacked on a pallet, based on the total weight of the pallet. The program should ask the user how much the pallet weighs by itself and with the widgets stacked on it. It should then calculate and display the number of widgets stacked on the pallet. (you can have partial widgets)
Create a Python program that asks the user how many miles they think they may run. The program should also ask them how much they weight. The program should then use a loop to calculate and print the number of calories burnt while running each mile. o Assume that a person burns 1 calorie per pound during each mile of running
Write a Java program that calculates how much a person would earn after a period of time, according to the following rules: 1. The starting salary for the first day is $1. 2. The salary will double each day. Ask the user to input the number of days worked. The output should display how much the salary was for each day worked, and show the total pay at the end of the work period. Get output similar to the sample...
Sylvia wants to lose 40 pounds. How many kcalories does this represent? Group of answer choices 105,000 85,000 140,000 3500 Flag this Question Question 2 1 pts If Paul eats 350 kcals less every day, how many kcalories does he not consume each week? Group of answer choices 2450 4000 3500 2280 Flag this Question Question 3 day? Group of answer choices 3.5 pounds 1.4 pounds 2.8 pounds 4.2 pounds Move To... This element is a more accessible alternative to...
Write a program and flowchart. The program should ask the user how many customers they want to track. Then, it asks for customer numbers, and sales by customer. At the end, it prints out the customer number, the customer sales, and then the total sales and average sales. You must use two different arrays, one for customer number, and one for sales. These are, in effect, parallel arrays. You must use a "while" loop to gather customer number and sales....
3,4, and 5 please! 15 points Answer the following questions. Please show your work to help justify your Show critical thinking skills Narrative. J.R is a 27-year-old male. He is 5 feet, 9 inches tall. He weights 187 pounds. He runs three days a week, a moderate pace, for 20 minutes. On the weekends, he enjoys doing yardwork, walking his dog, and hanging out with his friends. J.R. would like to improve his overall diet, and he has the following...
Write them in python IDLE ***** 5. Average Rainfall Write a program that uses nested loops to collect data and calculate the average rainfall over a period of years. The program should first ask for the number of years. The outer loop will iterate once for each year. The inner loop will iterate twelve times, once for each month. Each iteration of the inner loop will ask the user for the inches of rainfall for that month. After all iterations,...