Lab Assignment 2 Using input data in a program, variables & algorithms Due Date: 02 / 28 Your name and Lab assignment number must be included at the top of the Java source file in comments. Name your...

ask me if you need any information or files for the assignment.



Lab Assignment 2 Using input data in a program, variables & algorithms Due Date: 02 / 28 Your name and Lab assignment number must be included at the top of the Java source file in comments. Name your file and class name: LabAssign2_YourLastName On successful completion of this assignment, you will demonstrate the use and understanding of: • Obtaining user input through use of the Scanner class • Working with different variable types • Creating and implementing simple algorithms (using variables) • Displaying output Write a Java application which allows the user to enter the number of cookies he or she consumed. The program then calculates the total number of calories in the cookies eaten. Have the program calculate the number of cookies per serving and number of calories per cookie. Use variables to store all values needed for this program. The information about the cookies is as follows: Need to know information: A box of cookies holds 35 cookies. There are 10 servings in a box of cookies. Each serving has 250 calories. Display the output to the console formatted as shown. HINT: The real problem here is solving the math equation of CALORIES PER COOKIE with the variables you are given … • Think, 35 cookies per box with 10 servings per box means 35 / 10 = 1 serving • Store the above in a variable … maybe, cookiesPerServing • Then to find the CALORIES PER COOKIE you would just take the given calories per serving (250) and divided this by cookiesPerServing • Store this in a new variable, maybe, caloriesPerCookie • Lastly store user input using the scanner class of how many cookies they ate and multiply this by caloriesPerCookie An example of the programs output is shown below. Feel free to be creative and use your own text! Your program should compile with no errors to earn full points. CIT111TextBookExamples/build.xml Builds, tests, and runs the project CIT111TextBookExamples. CIT111TextBookExamples/build/classes/.netbeans_automatic_build CIT111TextBookExamples/build/classes/.netbeans_update_resources CIT111TextBookExamples/build/classes/chapter1/ComputeExpression.class package chapter1; public synchronized class ComputeExpression { public void ComputeExpression(); public static void main(String[]); } CIT111TextBookExamples/build/classes/chapter1/ShowLogicErrors.class package chapter1; public synchronized class ShowLogicErrors { public void ShowLogicErrors(); public static void main(String[]); } CIT111TextBookExamples/build/classes/chapter1/ShowRuntimeErrors.class package chapter1; public synchronized class ShowRuntimeErrors { public void ShowRuntimeErrors(); public static void main(String[]); } CIT111TextBookExamples/build/classes/chapter1/ShowSyntaxErrors.class package chapter1; public synchronized class ShowSyntaxErrors { public void ShowSyntaxErrors(); } CIT111TextBookExamples/build/classes/chapter1/Welcome.class package chapter1; public synchronized class Welcome { public void Welcome(); public static void main(String[]); } CIT111TextBookExamples/build/classes/chapter1/WelcomeWithThreeMessages.class package chapter1; public synchronized class WelcomeWithThreeMessages { public void WelcomeWithThreeMessages(); public static void main(String[]); } CIT111TextBookExamples/build/classes/chapter10/BMI.class package chapter10; public synchronized class BMI { private String name; private int age; private double weight; private double height; public static final double KILOGRAMS_PER_POUND = 0.45359237; public static final double METERS_PER_INCH = 0.0254; public void BMI(String, int, double, double); public void BMI(String, double, double); public double getBMI(); public String getStatus(); public String getName(); public int getAge(); public double getWeight(); public double getHeight(); } CIT111TextBookExamples/build/classes/chapter10/Course.class package chapter10; public synchronized class Course { private String courseName; private String[] students; private int numberOfStudents; public void Course(String); public void addStudent(String); public String[] getStudents(); public int getNumberOfStudents(); public String getCourseName(); public void dropStudent(String); } CIT111TextBookExamples/build/classes/chapter10/LargeFactorial.class package chapter10; public synchronized class LargeFactorial { public void LargeFactorial(); public static void main(String[]); public static java.math.BigInteger factorial(long); } CIT111TextBookExamples/build/classes/chapter10/Loan.class package chapter10; public synchronized class Loan { private double annualInterestRate; private int numberOfYears; private double loanAmount; private java.util.Date loanDate; public void Loan(); public void Loan(double, int, double); public double getAnnualInterestRate(); public void setAnnualInterestRate(double); public int getNumberOfYears(); public void setNumberOfYears(int); public double getLoanAmount(); public void setLoanAmount(double); public double getMonthlyPayment(); public double getTotalPayment(); public java.util.Date getLoanDate(); } CIT111TextBookExamples/build/classes/chapter10/PalindromeIgnoreNonAlphanumeric.class package chapter10; public synchronized class PalindromeIgnoreNonAlphanumeric { public void PalindromeIgnoreNonAlphanumeric(); public static void main(String[]); public static boolean isPalindrome(String); public static String filter(String); public static String reverse(String); } CIT111TextBookExamples/build/classes/chapter10/StackOfIntegers.class package chapter10; public synchronized class StackOfIntegers { private int[] elements; private int size; public static final int DEFAULT_CAPACITY = 16; public void StackOfIntegers(); public void StackOfIntegers(int); public void push(int); public int pop(); public int peek(); public boolean empty(); public int getSize(); } CIT111TextBookExamples/build/classes/chapter10/TestCourse.class package chapter10; public synchronized class TestCourse { public void TestCourse(); public static void main(String[]); } CIT111TextBookExamples/build/classes/chapter10/TestLoanClass.class package chapter10; public synchronized class TestLoanClass { public void TestLoanClass(); public static void main(String[]); } CIT111TextBookExamples/build/classes/chapter10/TestStackOfIntegers.class package chapter10; public synchronized class TestStackOfIntegers { public void TestStackOfIntegers(); public static void main(String[]); } CIT111TextBookExamples/build/classes/chapter10/UseBMIClass.class package chapter10; public synchronized class UseBMIClass { public void UseBMIClass(); public static void main(String[]); } CIT111TextBookExamples/build/classes/chapter2/ComputeArea.class package chapter2; public synchronized class ComputeArea { public void ComputeArea(); public static void main(String[]); } CIT111TextBookExamples/build/classes/chapter2/ComputeAreaWithConsoleInput.class package chapter2; public synchronized class ComputeAreaWithConsoleInput { public void ComputeAreaWithConsoleInput(); public static void main(String[]); } CIT111TextBookExamples/build/classes/chapter2/ComputeAreaWithConstant.class package chapter2; public synchronized class ComputeAreaWithConstant { public void ComputeAreaWithConstant(); public static void main(String[]); } CIT111TextBookExamples/build/classes/chapter2/ComputeAverage.class package chapter2; public synchronized class ComputeAverage { public void ComputeAverage(); public static void main(String[]); } CIT111TextBookExamples/build/classes/chapter2/ComputeChange.class package chapter2; public synchronized class ComputeChange { public void ComputeChange(); public static void main(String[]); } CIT111TextBookExamples/build/classes/chapter2/ComputeLoan.class package chapter2; public synchronized class ComputeLoan { public void ComputeLoan(); public static void main(String[]); } CIT111TextBookExamples/build/classes/chapter2/DisplayTime.class package chapter2; public synchronized class DisplayTime { public void DisplayTime(); public static void main(String[]); } CIT111TextBookExamples/build/classes/chapter2/FahrenheitToCelsius.class package chapter2; public synchronized class FahrenheitToCelsius { public void FahrenheitToCelsius(); public static void main(String[]); } CIT111TextBookExamples/build/classes/chapter2/SalesTax.class package chapter2; public synchronized class SalesTax { public void SalesTax(); public static void main(String[]); } CIT111TextBookExamples/build/classes/chapter2/ShowCurrentTime.class package chapter2; public synchronized class ShowCurrentTime { public void ShowCurrentTime(); public static void main(String[]); } CIT111TextBookExamples/build/classes/chapter3/AdditionQuiz.class package chapter3; public synchronized class AdditionQuiz { public void AdditionQuiz(); public static void main(String[]); } CIT111TextBookExamples/build/classes/chapter3/ChineseZodiac.class package chapter3; public synchronized class ChineseZodiac { public void ChineseZodiac(); public static void main(String[]); } CIT111TextBookExamples/build/classes/chapter3/ComputeAndInterpretBMI.class package chapter3; public synchronized class ComputeAndInterpretBMI { public void ComputeAndInterpretBMI(); public static void main(String[]); } CIT111TextBookExamples/build/classes/chapter3/ComputeTax.class package chapter3; public synchronized class ComputeTax { public void ComputeTax(); public static void main(String[]); } CIT111TextBookExamples/build/classes/chapter3/LeapYear.class package chapter3; public synchronized class LeapYear { public void LeapYear(); public static void main(String[]); } CIT111TextBookExamples/build/classes/chapter3/Lottery.class package chapter3; public synchronized class Lottery { public void Lottery(); public static void main(String[]); } CIT111TextBookExamples/build/classes/chapter3/SimpleIfDemo.class package chapter3; public synchronized class SimpleIfDemo { public void SimpleIfDemo(); public static void main(String[]); } CIT111TextBookExamples/build/classes/chapter3/SubtractionQuiz.class package chapter3; public synchronized class SubtractionQuiz { public void SubtractionQuiz(); public static void main(String[]); } CIT111TextBookExamples/build/classes/chapter3/TestBooleanOperators.class package chapter3; public synchronized class TestBooleanOperators { public void TestBooleanOperators(); public static void main(String[]); } CIT111TextBookExamples/build/classes/chapter4/ComputeAngles.class package chapter4; public synchronized class ComputeAngles { public void ComputeAngles(); public static void main(String[]); } CIT111TextBookExamples/build/classes/chapter4/FormatDemo.class package chapter4; public synchronized class FormatDemo { public void FormatDemo(); public static void main(String[]); } CIT111TextBookExamples/build/classes/chapter4/GuessBirthday.class package chapter4; public synchronized class GuessBirthday { public void GuessBirthday(); public static void main(String[]); } CIT111TextBookExamples/build/classes/chapter4/HexDigit2Dec.class package chapter4; public synchronized class HexDigit2Dec { public void HexDigit2Dec(); public static void main(String[]); } CIT111TextBookExamples/build/classes/chapter4/LotteryUsingStrings.class package chapter4; public synchronized class LotteryUsingStrings { public void LotteryUsingStrings(); public static void main(String[]); } CIT111TextBookExamples/build/classes/chapter4/OrderTwoCities.class package chapter4; public synchronized class OrderTwoCities { public void OrderTwoCities(); public static void main(String[]); } CIT111TextBookExamples/build/classes/chapter5/Dec2Hex.class package chapter5; public synchronized class Dec2Hex { public void Dec2Hex(); public static void main(String[]); } CIT111TextBookExamples/build/classes/chapter5/FutureTuition.class package chapter5; public synchronized class FutureTuition { public void FutureTuition(); public static void main(String[]); } CIT111TextBookExamples/build/classes/chapter5/GreatestCommonDivisor.class package chapter5; public synchronized class GreatestCommonDivisor { public void GreatestCommonDivisor(); public static void main(String[]); } CIT111TextBookExamples/build/classes/chapter5/GuessNumber.class package chapter5; public synchronized class GuessNumber { public void GuessNumber(); public static void main(String[]); } CIT111TextBookExamples/build/classes/chapter5/GuessNumberOneTime.class package chapter5; public synchronized class GuessNumberOneTime { public void GuessNumberOneTime(); public static void main(String[]); } CIT111TextBookExamples/build/classes/chapter5/MultiplicationTable.class package chapter5; public synchronized class MultiplicationTable { public void MultiplicationTable(); public static void main(String[]); } CIT111TextBookExamples/build/classes/chapter5/Palindrome.class package chapter5; public synchronized class Palindrome { public void Palindrome(); public static void main(String[]); } CIT111TextBookExamples/build/classes/chapter5/PrimeNumber.class package chapter5; public synchronized class PrimeNumber { public void PrimeNumber(); public static void main(String[]); } CIT111TextBookExamples/build/classes/chapter5/RepeatAdditionQuiz.class package chapter5; public synchronized class RepeatAdditionQuiz { public void RepeatAdditionQuiz(); public static void main(String[]); }
Feb 26, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here