Write large programs by adding a little bit at a time

Assignment Help JAVA Programming
Reference no: EM132230576

Question: Input and Nested If Statements and Functions

This assignment is more exercise with conditional statements and code to make your program more robust. It builds on what you learned in the previous assignment in that you must now use else conditions and conditional blocks. This assignment should help you remember how to use if, else, blocks, and nested if statements in case you need a refresher.

The exercise is designed in a special way to show you how you should write large programs by adding a little bit at a time. Please do these steps one at a time. The practice you will follow is called "refactoring."

Start by creating a function to get in integer from user input. Name that function, getUserValue_step1(). To show your work increments, implement each step as a separate function, called getUserValue_step2(), getUserValue_step3(), getUserValue_setp4() and getUserValue_setp5(). Each time, copy the code from the previous step, and then add the new modifications to the new function. Be aware that you will not always be adding to the end of the new function, and may even have to rearrange the order of the previous pieces, in order to satisfy the new expectations presented in one or more of the steps.

To test your code, call the function for whichever step you are working on from main().

Step1. Write the code that prompts the user to enter an integer between 1 and 20 (including 1 and 20), reads the value using Scanner, and then prints the value that they entered in a statement that begins with "You entered a ".

Step2. Add more code or modify your code so that if the user enters a value that is less than 1 or greater than 20, it prints out "The value you entered is not between 1 and 20." Otherwise, and only if the value is between 1 and 20, it prints the statement as before.

Step3. Add more code or modify your code so that if the user enters the values 8, 11, or 18, the statement that is printed is "You entered an" instead of "You entered a". Note in putting these things in a particular order, that testing for 8, 11, and 18 makes more sense if you already know that the number is between 1 and 20.

Step4. Add more code or modify your code so that if the user enters something that is not a number, i.e. includes letters, your program does not print any of the above lines, but instead prints out "Idiot! Your input could not be read as a number. Get a life!". Again, note that it doesn't make sense to test something to see if it is between 1 and 20 if it isn't even a number. So sequence your tests in a logical order of ruling out the various cases.

Step5. Add more code or modify your code so that if the user enters something invalid or an integer not between 1 and 20 print invalid input and keep asking the user to input a number until a valid number between 1 and 20 is entered and then prints out the correct response.

Include comments in your code to explain what each of the ‘if' statements is testing.

Zip the java file in a single zip file and submit the zip file.

Reference no: EM132230576

Questions Cloud

Research the available cloud-based applications : You believe that a cloud-based solution is the best way for the company to meet its objectives. In order to convince the company management.
What is information stewardship : What is information stewardship? How is information stewardship used in managing an organizational IM framework? Give a specific example. Why is it important?
What are the specific characteristics of countermeasures : The question you'll address is: "What are the specific characteristics of countermeasures required to protect national infrastructure from emerging threats.
Evaluate prototyping as a technique : CIS110 Evaluate prototyping as a technique for gathering quality business requirements. Determine the approach to prototyping that would be better suited.
Write large programs by adding a little bit at a time : The exercise is designed in a special way to show you how you should write large programs by adding a little bit at a time. Please do these steps one at a time.
Explain with examples the components of pki : Use internet resources to research for information about the history of Cryptography. Write a 2-3 pages research paper answering these questions.
What role end-users typically play in incident reporting : Search "scholar.google" or your textbook. Discuss what role end-users typically play in incident reporting? Should end users be encouraged to report suspicious.
Implement a doubly linked list with a sentinel node : Implement a Doubly Linked List with a sentinel node. The class should support find , insertion() and remove() operations from head and tail of the list.
What was the scoop-deliverable and results of the project : What was the scoop, deliverable, and results of the project? If you had to do the same project again, what changes will you recommend?

Reviews

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd