Assignment 6 For this assignment, you'll prompt the user for a number. While we've done this before, this time, we're going to make the input a little more sophisticated by moving it to a new method that will capture the number as well as make sure the number is within the correct range. By separating logic like this into methods, you can see how easy it can be to reuse this logic any time you need to get input by just calling a simple method. Create a method GetNumber that is: • public • static • returns an int • accepts 2 parameters, an int for lower limit and an int for upper limit Logic within the method should do the following: 1. Prompt the user to enter a number between the lower and upper limit specified; see the format below expected below. 2. Check if the number entered is valid, falling within the lower and upper ranges specified. If the number is not valid, continue to prompt the user until a valid number is entered 3. Return the validated number from the method. From the main method, call the GetNumber method using inputs of 0 and 10. Then, print the statement You entered X, where X is the number returned from the method. Sample Output The following example assumes the method is called with a lower limit of 0 and upper limit of 10: Enter a number between 0 and 10: 42 Enter a number between 0 and 10: -5 Enter a number between 0 and 10: 8 You entered 8

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter7: Using Methods
Section: Chapter Questions
Problem 1CP
icon
Related questions
Question
100%

Hello, I need help with this assignment, please. I need to prompt the user for a number using multiple methods in a single class. This has to be done through #C language and I am doing it through Visual Studio, have tried to solve this but I failed to get the right outputs, its really confusing to me, thank you for your help.

Assignment6.pdf
>
Assignment 6
●
For this assignment, you'll prompt the user for a number. While we've done this before, this time, we're
going to make the input a little more sophisticated by moving it to a new method that will capture the
number as well as make sure the number is within the correct range.
●
By separating logic like this into methods, you can see how easy it can be to reuse this logic any time you
need to get input by just calling a simple method.
Create a method GetNumber that is:
1 / 1
public
static
3.
TT
returns an int
accepts 2 parameters, an int for lower limit and an int for upper limit
W
Logic within the method should do the following:
1.
Prompt the user to enter a number between the lower and upper limit specified; see the format
below expected below.
2. Check if the number entered is valid, falling within the lower and upper ranges specified. If the
number is not valid, continue to prompt the user until a valid number is entered
Return the validated number from the method.
From the main method, call the GetNumber method using inputs of 0 and 10. Then, print the statement
You entered X, where X is the number returned from the method.
Enter a number between 0 and 10:
42
Enter a number between 0 and 10:
-5
Enter a number between 0 and 10:
8
You entered 8
Sample Output
The following example assumes the method is called with a lower limit of 0 and upper limit of 10:
12.0 X
:
More options
Transcribed Image Text:Assignment6.pdf > Assignment 6 ● For this assignment, you'll prompt the user for a number. While we've done this before, this time, we're going to make the input a little more sophisticated by moving it to a new method that will capture the number as well as make sure the number is within the correct range. ● By separating logic like this into methods, you can see how easy it can be to reuse this logic any time you need to get input by just calling a simple method. Create a method GetNumber that is: 1 / 1 public static 3. TT returns an int accepts 2 parameters, an int for lower limit and an int for upper limit W Logic within the method should do the following: 1. Prompt the user to enter a number between the lower and upper limit specified; see the format below expected below. 2. Check if the number entered is valid, falling within the lower and upper ranges specified. If the number is not valid, continue to prompt the user until a valid number is entered Return the validated number from the method. From the main method, call the GetNumber method using inputs of 0 and 10. Then, print the statement You entered X, where X is the number returned from the method. Enter a number between 0 and 10: 42 Enter a number between 0 and 10: -5 Enter a number between 0 and 10: 8 You entered 8 Sample Output The following example assumes the method is called with a lower limit of 0 and upper limit of 10: 12.0 X : More options
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Math class and its different methods
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,