Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have a C# hw in Visual studio, Please I need help with it, it needs to be done in Visual studio and needs comments

I have a C# hw in Visual studio, Please I need help with it, it needs to be done in Visual studio and needs comments in every line so i can do it by myself,

Please read the things very clearly, I have put all the screenshots of output like how it will look like...

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

At the end the program exist.. by entering 3

Get an integer from the user Get an integer from the user We'll use this a lot, so convert that to an int and put the result in a different variable Write out that the factors of their input are: Use a For loop to create numbers from 1 to the user's number. In the loop: Get the remainder by dividing the user's number by the For loop number User's number % For loop variable gives you the remainder If the remainder is zero then the loop variable is a factor of the user variable. Write that out. Use Write and some clever thought to make your output look like mine. Outside of the loop do a readkey Some Sample output Enter an integer to find its factors: 26 The factors of 20 are: 1 2 4 5 10 20 Enter an integer to find its factors: 1001 The factors of 1001 are: 1 7 11 13 77 91 143 1001 Now comment all the lines of code that you wrote except for the part where you ask for and get the integer from the user and make a handy int variable to hold the input. But use different variable names. Make a loop that makes the numbers from 1 to the user input. In that loop Write that the factors of the user inputs are Make another loop that makes the numbers from one to the current value of the outside loop. Inside that loop a Get the remainder by dividing the outer loop number by the inner loop number outer loop number % inner loop number gives you the remainder If the remainder is zero then the loop variable is a factor of the user variable Write that out. Use Write and some clever thought to make your output look like mine Sample Output teger to find the factor of all lesser tegers leading up to, and including, your number: 11 The factors of 1 are: 1 The factors of 2 are: 1 2 The factors of 3 are: 1 3 The factors of 4 are: 1 2 4 The factors of 5 are: 1 5 The factors of 6 are: 1 2 3 6 The factors of 7 are: 1 7 The factors of 8 are: 1 2 4 8 The factors of 9 are: 139 The factors of 10 are: 1 2 5 10 The factors of 11 are: 1 11 Super! Now make a menu to get user choice input. Then use a switch statement to either find the factors of a single integer, find the factors of all integers up to and including a single integer, or fall out of the switch with any other choice. It should look like my output on the next screen. Note: after they give the menu input: On the next line use Console.Clear) That will clear the console screen and make for a nicer transition. (1) Get all the factors for a specific integer (2) Get all the factors for a specific integer and all lesser positive integers (3) Exit Please enter your choice here: It will actually exit if the user enters 3 or anything other than 1 or 2 Almost done! Now let's wrap the whole thing in a While statement. Instead of doing while(true), set a variable to zero in the line before your while statement. Then say while(thatVariable 0) and put all of our code so far in the While brackets. For case "3" set thatVariable-1, then do the break statement that every case has. When that hits the While statement it will end the program Assuming you don't have more code after the While statement. Tips: Write small bits then test s Use unique variables for each block of code, unless you are bringing in an outer variable to use on an inner block I know, for a fact, that you can do this! It may feel impossible but follow my steps, use Console.WriteLine) to see what's going on. Step away for a bit if you have hit a wall. Once he enters 1: all the a specific integer (2) Get all the factors for a specific integer and all lesser positive integers (3) Exit lease enter your choice here:1 factors: 55 The factors of 55 are: 15 11 55 ress any key to continue After press any kev to continue: After press any key to continue: (1) Get all the factors for a specific integer 2) Get all the factors for a specific integer and all lesser positive integers (3) Exit Please enter your choice here: 2 Enter an integer to find the factor of al1 lesser integers leading up to, and including, your number: Enter an integer to find the factor of al1 lesser integers leading up to, and including, your number: 12 he factors of 1 are: 1 he factors of 2 are: 1 2 The factors of 3 are: 1 3 The factors of 4 .re; 124 The factors of 5 are: 1 5 he factors of 6 are: 1 2 3 6 The factors of 7 are: 1 7 The factors of 8 are: 1 24 8 The factors of 9 are: 1 39 The factors of 10 are: 1 25 18 The factors of 11 are: 1 11 he factors of 12 are: 1 2 346 12 ess any key to continue

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft Visual Basic 2005 For Windows Mobile Web Office And Database Applications Comprehensive

Authors: Gary B. Shelly, Thomas J. Cashman, Corinne Hoisington

1st Edition

0619254823, 978-0619254827

More Books

Students also viewed these Databases questions