Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a single program to perform each of the below tasks one at a time. You ma

ID: 3802522 • Letter: C

Question

Create a single program to perform each of the below tasks one at a time. You may substitute hugs for something else you may enjoy such as chocolates, strawberries, etc., as long the submitted version contains nothing crude or profane. DO NOT USE if STATEMENTS – USE while-loops, do—while loops (do-loops) or for-loops based on what actions need to be done. Provide the user some hints on what you would like them to enter, such as asking them to enter Y or N, YES, NO, OK, Nope, a value, range of values, a letter, etc. (3 pts) Comment your code discussing WHAT the code does and HOW the code does its job. (3 pts) Ensure Indents are used properly to show what code belongs to what loops. (3 pts) As always, ensure the file class name ENDS with your initials. Upload when complete. ( 3pts) Work on this in lab unless you have a valid excuse (3 pts) Write code to perform the following operations: (3 pts each)

1. Need a hug? (Use a while-loop) a. Ask the users name – use their name throughout the program. b. Display “Part 1!” c. Ask the user if they need a hug. d. If the response is positive, give them (display) a {{ HUG! }}. e. Ask if they would like another. Loop back to part 1.d and repeat

. 2. Enough hugs? (Use a do-loop) a. Display “Part 2!” b. Give the user a {{ BIG HUG }} without asking. c. Ask them if they’ve had enough hugs. d. Loop back to part 2.b until they enter YES! exactly

3. Lotsa Hugs! (Use a for-loop) a. Display “Part 3!” b. Give the user 10 {{ HUGS }}

4. How many hugs? (Use a do-loop and a for-loop) a. Display “Part 4!” b. Ask the user how many hugs they would like. c. If they enter a value less than 3, then display that is not enough hugs! Loop back to 4.b. d. Give them the number of hugs they ask for while counting them off: {{ HUG 1 }} {{ HUG 2 }} etc

5. Another round? (Use a couple do-while loops…) a. Display “Part 5!” b. Ask the user if they would like have another round of hugs. c. Loop back to 5.b unless they enter Y or N. d. If they enter Y, loop back to 1b. e. If not, display “Goodbye!” and end the pr

Explanation / Answer

Here is the source code for the above in c#, Please let me know in case of any issues:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp3
{
class Program
{
static void Main(string[] args)
{
bool Conthugs = true;
while (Conthugs)
{
bool cont = true;
string name = "", response;
Console.WriteLine("What is your Name"); // Ask User Name
name = Console.ReadLine();
Console.WriteLine("Part 1!"); // Part 1
while (cont)
{
Console.WriteLine("Do you need Hug: Press Y for Yes Press N for No"); // Part 1.c
response = Console.ReadLine();
switch (response)
{
case "Y":
Console.WriteLine("Here are hugs for you");
Console.WriteLine("Do you need some more hug: Press Y for Yes Press N for No");
response = Console.ReadLine(); // Part 1.d
break;
case "N":
cont = false;
break;
}
}
//#2
Console.WriteLine("Part 2!");
do
{
Console.WriteLine("Here is {Big Hug} for you");
Console.WriteLine("You have had enough hugs: Press Yes! for Yes Press No! for No");
response = Console.ReadLine();
}
while (response != "Yes!");

// #3
Console.WriteLine("Part 3!");
for (int hugs = 0; hugs < 10; hugs++)
{
Console.WriteLine("Here is {Hug} for you");
}

// #4
Console.WriteLine("Part 3!");
int noofHugs = 0;
do
{
Console.WriteLine("Hey {0} How many hugs would like to have", name);
noofHugs = Convert.ToInt16(Console.ReadLine());
if (noofHugs < 3)
Console.WriteLine("Hey {0} These are not enough Hugs", name);
else
for (int hugs = 0; hugs < noofHugs; hugs++)
{
Console.WriteLine("Here is Hug {0} for you", hugs + 1);
}

}
while (noofHugs < 3);

// #5
Console.WriteLine("Part 5!");
string resp5;
bool contpart5 = true;
do
{
Console.WriteLine("Hey {0} Would you like to have another round of hugs", name);
resp5 = Console.ReadLine();
switch (resp5)
{
case "Y":
Conthugs = true; // Go back to 1.B
contpart5 = false;
break;
case "N":
Conthugs = false;
Console.WriteLine("GoodBye!!");//Exit
contpart5 = false;
break;
default:
break;
}

}
while (contpart5); // Do until user press Y or N
}
}
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote