The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 313 Weeks Ago, 6 Days Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
Hello,Divymital,
Please, help me with my homework. It should be written on C#
Thank you in advance,
Yuliya
IT 1050 – Programming Logic
Take Home Test 1
3 points per problem – 48 points
1.      Create an infinite while loop. Use a Boolean variable called keepLooping that set to true in the loop’s termination condition. Hint: Use CTRL+C or Debug -> Terminate All to end the program.
inti = 14;
BooleankeepLooping = true;
while (keepLooping) ;
           {
if (i<= 13) ;
keepLooping = false;
i++;
Console.WriteLine(i);
           }
Â

Â
Â
2.      Write a while loop to prints 1 through6 in square brackets:
Â
 [1] [2] [3] [4] [5] [6]
Â
inti = 1, n = 6;
while (i<= n)
           {
Console.Write(" [" + i + "] ");
i++;
Â
           }
Â
Console.WriteLine();
Console.ReadLine();
       }
Â
Â

Â
3.      Write a for loop that computes the sum of first n positive integers. Set the variable n to 12. Print “The sum of all integers from 0-12 is “ + sum
sum = 1 + 2 + 3 + … + n
4.      Write a for loop that prints 1through n, separated by commas. Example: for n = 9 print
Â
1, 2, 3, 4, 5, 6, 7, 8, 9
Â
5.      Write a while loop that prints all even numbers 0 through n, separated by commas. Example: for n = 20 print
Â
0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20
Â
6.      Write a while loop that prints all odd numbers 1 through n, separated by commas. Example: for n = 15 print
Â
1, 3, 5, 7, 9, 11, 13, 15
Â
7.      Given the following code, For n = 7 what is the output?
int n;
inti = 0; // initialize
do {
Console.Write("*");
i++; // update!
} while (i< n); // test!
Console.WriteLine();
Â
Â
How is it different from the while loop?
Â
8.      Write a sentinel loop that adds all of the numbers input by the end user and outputs the sum. End on a sentinel value input by the user as -1. The prompt should indicate that the user should input -1 to end.
Â
9.      Write an if-else statement that takes accepts a numeric input for month (example: 1-Jaunary) and outputs the month description. For example, if the user inputs 4, it will output April.
Â
10.  Re-write problem 9 using a switch statement.
Â
11.  How do we combine multiple Boolean values? Give 3 primary operators that we use when working with multiple Boolean values.
Â
12.  Use nested for loops to print a matrix of asterisks with input values numColumns and numRows. Example output for numColumns = 10 and numRow = 3:
**********
**********
**********
13.  What is an off-by-one error? Create a loop demonstrating off by one – please describe what is happening. Also show the corrected code. Use < in the incorrect version and <= in the correct version of the loop.
Â
14.  There is a method called Substring that we can use with a string to look at a portion of a string. For example, the following code will print the letter a.
string input = "abcdef";
Console.WriteLine(input.Substring(0, 1));
Â
Given the following input, create a loop that uses the Substring method to count the number of times the letter ‘z’ occurs in a string input by the user.
Â
               asdfojiaqweb;ounqwrb;ounwqen;zzznbnaozonza
Â
Hint: increment the 1st argument in the Substring method call. You must use the Substring method in a loop to get credit!
15.  Use a for loop to print the following to the console:

16.  Input a number from user and displays power of the number. Ask user’s to whether continue or not. If user presses ‘y’ or ‘Y’ then continue and again accept a number. If user presses any other characters or numbers then quit.
Attachments:
----------- Â ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly