Chat with us, powered by LiveChat In this module, you have studied how to use conditionals and logical structures to create branches or 'forks in the code.' In Stepping Stone Lab Three, you will put this emerging knowledge - EssayAbode

In this module, you have studied how to use conditionals and logical structures to create branches or ‘forks in the code.’ In Stepping Stone Lab Three, you will put this emerging knowledge

 In this module, you have studied how to use conditionals and logical structures to create branches or "forks in the code." In Stepping Stone Lab Three, you will put this emerging knowledge into practice by developing a branching structure for the Stepping Stone program. 

 To complete this assignment, review the following documents: 

Stepping Stone Lab Three Guidelines

Branches

Overview: In this module, you have studied how to use conditionals and logical structures to create branches or "forks in the code." In Stepping Stone Lab Three, you will put this emerging knowledge into practice by developing a branching structure for the recipe manager program.

Be sure to review the Stepping Stone Three guidelines before beginning this lab. The completed code (.java file) from Stepping Stone Lab Two is included in this module to use as a reference for comparison of your work in Module Three as well as moving forward. This code serves a number of functions:

· It allows you to review your own submitted code.

· You may utilize it as a useful foundation for Stepping Stone Three as well as other assignments to come.

· Together with instructor feedback on your submitted code, you are building your own final project application.

Prompt: In Stepping Stone Three, you will write a short application that uses conditionals to create a "forked" branching structure for the recipe manager.

Whenever a program accepts user input, it is best practice to be sure the input is what you as the programmer expect. As you continue to develop the recipe manager, you will need to be able to validate user input and ensure that the user enters values that are valid. In this lab, you will write a short program that first, tests that the input is numerical, then checks that the number is within a specific range, and checks that the maximum number of cups of our main ingredient is 100 and that the minimum number of cups is 1.

This application uses the Scanner class to accept a number between 1 and 100 from the user. The Scanner class is useful for parsing primitive values, including numbers.

Specifically, you will create a branching structure that leads to the following output:

If the number entered is between 1 and 100 (inclusive), the application will display a message that says, "is a valid number of cups!".

However, if the number entered is not between 1 and 100 (inclusive), error messages will be displayed to inform the user that the entry does not fit the expected range: "is not a valid number of cups!" and "Please enter another number of cups between 1 and 100.".

Guidelines for Submission: This assignment should be submitted as a Java file.

Extending This Lab for Your Final Project

For your final project, adapt your Ingredient Java file to include data-type validation steps for each of the variables in the class:

· ingredientName (String)

· ingredientAmount (float)

· unitMeasurement (String)

· Number of calories (double)

,

/* * 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 SteppingStones; import java.util.Scanner; public class SteppingStone3_Branches { public static void main(String[] args) { int numberCups = -1; /** * Add a CONSTANT variable MAX_CUPS assigned to the value 100 */ Scanner scnr = new Scanner(System.in); System.out.println("Please enter the number of cups (between 1 and 100): "); //The following "if branch" uses the scanner method hasNextInt() to //check to see if the input is an int. if (scnr.hasNextInt()) { numberCups = scnr.nextInt(); /**NESTED BRANCH: * Insert a nested branch that follows the following pattern: * * if numberCups is less than or equal to MAX_CUPS: * print numberCups + " is a valid number of cups!" * * else: * print numberCups + " is not a valid number of cups!" * print "Please enter another number of cups between 1 and 100: " * numberCups = scnr.nextInt(); * * if numberCups is less than or equal to MAX_CUPS: * print numberCups + " is a valid number of cups!" * * else if numberCups < 1: * print numberCups + "is less than 1. Sorry you are out of" * attempts." * * * else * print numberCups + "is greater than 100. Sorry you are out of * attempts." * */ } } else { System.out.println("Error: That is not a number. Try again."); } } } /** * * For your Final Project, adapt your Ingredient java file to include * data-type validation steps for each of the variables in the class: * * ingredientName (String) * ingredientAmount (float) * unitMeasurment (String) * number of Calories (double) * */

Related Tags

Academic APA Assignment Business Capstone College Conclusion Course Day Discussion Double Spaced Essay English Finance General Graduate History Information Justify Literature Management Market Masters Math Minimum MLA Nursing Organizational Outline Pages Paper Presentation Questions Questionnaire Reference Response Response School Subject Slides Sources Student Support Times New Roman Title Topics Word Write Writing