Software

profilespike34
IngredientCalculator.docx

/*

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

package homework;

import java.util.Scanner;

/**

*

* @author onur

*/

public class SteppingStone2_IngredientCalculator {

/**

* @param args the command line arguments

*/

public static void main(String[] args) {

/**

*Assign the following variables with the appropriate data type and value:

*VARIABLE NAME VALUE

*nameOfIngredient ""

*numberCups 0

*numberCaloriesPerCup 0

*totalCalories 0.0

*/

String nameOfIngredient;

float numberCups;

int numberCaloriesPerCup;

double totalCalories;

Scanner scnr = new Scanner(System.in);

System.out.println("Please enter the name of the ingredient: ");

nameOfIngredient = scnr.next();

System.out.println("Please enter the number of cups of " + nameOfIngredient + " we'll need: ");

numberCups = scnr.nextFloat();

System.out.println("Please enter the number of calories per cup: ");

numberCaloriesPerCup = scnr.nextInt();

/**

* Write an expression that multiplies the number of cups

* by the Calories per cup.

* Assign this value to totalCalories

*/

totalCalories = numberCaloriesPerCup + numberCups;

System.out.println(nameOfIngredient + " uses " + numberCups + " cups and has " + totalCalories + " calories.");

}

}