Learning Goal: I’m working on a java exercise and need guidance to help me learn

Learning Goal: I’m working on a java exercise and need guidance to help me learn.(1) Write a program that calculates the energy needed to heat water from an initial temperature to a final temperature. Your program should prompt the user to enter the amount of water in kilograms and the initial and final temperatures of the water. The formula to compute the energy is Q = M * (finalTemperature – initialTemperature) * 4184where M is the weight of water in kilograms, initial and final temperatures are in Celsius, and energy is measured in joules. Here is a sample run:*Note: the values entered are shown under the prompt but are not actually part of the output of the program.Enter the amount of water in kilograms:55.5Enter the initial temperature:3.5Enter the final temperature:10.5The energy needed is 1625484.0Use the code template below to answer the first question:public class CalculateEnergy {public static void main(String[] args) { java.util.Scanner scnr = new java.util.Scanner(System.in); System.out.print(“Enter the amount of water in kilograms: “); double m = /* FIX ME with scnr.nextDouble(); */ System.out.print(“Enter the initial temperature: “); double f = /* FIX ME too */ System.out.print(“Enter the final temperature: “); double i = /* FIX ME too */ System.out.println(“The energy needed is ” + /* FIX ME–do the math here */ ); }}2) Problem AJimmy and 4 of his friends are at the movies and he was asked to purchase the snacks. The prices are as follows:popcorn: $5.75candy bar: $1soda: $1.50water: $1Calculate the price of buying p bags of popcorn, c candy bars, s sodas, and w waters.They all agreed to split the price evenly, calculate the amount each person should pay.Problem BJane is planning to put a new fence around her flower garden. She wants to change the shape, but doesn’t want to change the amount of space it occupies. It is currently a square that has sides of length squareSide. She wants to make it a rectangle with one set of parallel sides twice the length of the other set of parallel sides. What should the length of the sides be?Data Type Hint: Can you purchase half a bag of popcorn/candy bar/soda/water? Does it make sense to have decimals for these variables? What about for the price or the length of a fence side?Printing floating point numbersStudents can spend hours trying to get output to match. Suppose the statementSystem.out.println(“Volume is ” + volume);`outputs this value for volumeVolume is 56.43531235683212352099798but the expected output in the grading program isVolume is 56.435312356832123520998For grading, we introduce a new method printf(). The f stands for “format” and we can use it to limit the number of digits following the decimal point to enforce a lesser degree of precision and rounded output. The new statement looks like thisSystem.out.printf(“Volume is %8.5f”, volume);or with a newlineSystem.out.printf(“Volume is %8.5fn”, volume);Now the output isVolume is 56.43531and the grading program–and the student–can be happy!Use the code template below to answer the second question please:public class WordProblems { public static void main(String[] args) { //ID comment goes here!!!!! /* Your variables go here! Including the Scanner*/ /*Solution to Problem A the numbers are read in the order of price listing (p,c,s,w)*/ System.out.println(“Price of the snack: $” + /*your variable(s) name*/); System.out.println(“Individual price: $” + /*your variable(s) here*/); /*Solution to Problem B Note: the squareroot function is Math.sqrt(variable) */ System.out.printf(“Length of long side: %6.5fn” + /*your variable here*/); System.out.printf(“Length of short side: %6.5fn” + /*your variable here*/); }}

Save your time – order a paper!
Get your paper written from scratch within the tight deadline. Our service is a reliable solution to all your troubles. Place an order on any task and we will take care of it. You won’t have to worry about the quality and deadlines

Order Paper Now

“Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!”

"Do you need a similar assignment done for you from scratch? We have qualified writers to help you with a guaranteed plagiarism-free A+ quality paper. Discount Code: SUPER50!"

order custom paper