Question
Given the following was entered from the keyboard: 1 you displayed: Enter number of cookies eaten:Your calorie intake was: 75 calories So where is my
Given the following was entered from the keyboard: 1 you displayed: Enter number of cookies eaten:Your calorie intake was: 75 calories So where is my java error in the following: import java.util.Scanner; /** * @author * */ public class CookieCalorieCounter { /** * @param args */ public static void main(String[] args) { Scanner scanner = null; try { scanner = new Scanner(System.in); // prompt read the number of cookies eaten System.out.print("Enter number of cookies eaten:"); int cookieCount = scanner.nextInt(); int servingSize = 40 / 10; int caloriesPerCookie = 300 / servingSize; int totalCalories = cookieCount * caloriesPerCookie; // print the result console System.out.println("Your calorie intake was: " + totalCalories + " calories"); } catch (Exception e) { // TODO: handle exception } finally { if (scanner != null) { scanner.close(); } } } } instead of: Enter number of cookies eaten: Your calorie intake was: 75 calories.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started