jeudi 17 novembre 2016

Loops, various forms of control flow, and interaction with the user

Dont worry I'm not looking for actual coding help to pass off as my own. Just a helping hand to push me in the right direction and explain what exactly is I'm being asked to do so I can get started. This is actually an old assignment that I never understood and ended up not submitting, but my current assignment is largely based off the skills I should have obtained throughout this assignment. So I'd really appreciate any help. (A background on my programming/coding knowledge would be beginner.)

"Write a program called Interact.java. Give the user four options repeatedly:

Enter a new number
Show the current number as centered pluses
Show the lowest entered number as stars
Show the absolute difference of the last two numbers

These options should do the following.

The first option should ask the user to input a number between 1 and 40 (inclusive). If the number is not in this range, the program should STOP. Make sure that your program really does stop before submitting! The way to stop the program is simply to reach the end of the code (as in previous weeks).
The second option should print the current number as a sequence of pluses, surrounded by minuses, so that 40 characters are printed in total.
The third option should print a number of stars equal to the lowest ever entered number (0 if no number was entered yet). The stars should be preceded by minus signs, so that in total exactly 40 characters are printed.
Example: -----------------------------------***** if the lowest number was 5.
The fourth option shows the absolute difference of the two most recently entered numbers.
    If no numbers have been entered yet, it should show 0.
    If one number has been entered, it should show that number.
    If at least two numbers have been entered, it should show the largest number minus the smallest number.
The output must be of the following form:

      The absolute difference of the last two numbers is 5.

After completing an option, the program should always show the menu above again, unless the user entered a number outside the range of 1 to 40 in option 1. The program should stop in that case. The program should also stop if the user selects a number different from 1,2,3,4 in the menu above. You may assume that the user only enters integers."

Aucun commentaire:

Enregistrer un commentaire