Question: Question 1 Convert the following loop into a for loop bool keepGoing = true; int count = 0 ; while ( keepGoing & & count

Question 1
Convert the following loop into a for loop
bool keepGoing = true;
int count =0;
while (keepGoing & & count 3)
{
Console.WriteLine(count);
Console.WriteLine("Keep going?");
keepGoing = Convert.ToBoolean(Console.ReadLine());
count++;
}
Question 2
The code in question 2 currently has no validation. Check for the following cases:
Non-numeric input
Negative number input
Number greater than 19,000,000 input
If any of the validation cases are encountered, output "error" to the user. Other deposit amount to the user.
Question 3
Convert the following if-else into a switch case:
Console.WriteLine("Enter a username");
string ulnput = Console.ReadLine();
if (ulnput == "admin")
Console.WriteLine("Nice try");
else if (ulnput == "user")
Console.WriteLine("Too common!");
else if (ulnput == "password")
Console.WriteLine("That comes later");
else
Console.WriteLine("Username set!");
Question 4
Write a program to simulate feeding ducks at a park.
Repeat the following commands until the user wants to stop feeding ducks or has fed 20 ducks:
Ask the user how many ducks they would like to feed
Display the number of ducks the user has fed
Ask the user if they would like to continue
If repetition stops because the user fed 20 ducks or more, display the message "you have been overwhelmed by ducks."
Question 5
Complete the method addingEvens()
The method has an integer return and two integer parameters
The method returns the sum of all even integer parameter values
A value is even if it is divisible by 2.
0 is considered an even number for this problem
If no parameters are even, the method returns-1
For example: addingEvens (2,4) returns 6, addingEvens (3,8) returns 8, addingEvens returns -1
Call the method from the main 3 times with the following arguments
Two even numbers
One even and one odd number
Two odd numbers
 Question 1 Convert the following loop into a for loop bool

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!