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
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
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images
Knowledge Booster
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.Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education