Question

In: Computer Science

How to write this mini program in C# - (C sharp please) There are 3 squirrels...

How to write this mini program in C# - (C sharp please)

There are 3 squirrels and winter begins in roughly 12 weeks

Each week, a squirrel will manage to stash away anywhere

from 10 to 20 acorns

Each week, display the following:

The number of weeks before winter

The number of acorns each squirrel stashed away that week

The total number of acorns each squirrel has stashed away

Bonus: display the number of acorns stashed each month as

asterisks (*)

Solutions

Expert Solution

//C# program

using System.IO;
using System;

class Program
{ public static int RandomNumber(int min, int max)
{
Random random = new Random();
return random.Next(min, max);
}
static void Main()
{
int week =12;
int total=0;
int i;
for(i=1;i<=week;i++){
Console.WriteLine("Week before winter " + (week-i));
int s1 = RandomNumber(10,20);
int s2 = RandomNumber(10,20);
int s3 = RandomNumber(10,20);
Console.WriteLine("The number of acorns squirrel1 stashed away in week " +i+ " is " + s1);
Console.WriteLine("The number of acorns squirrel2 stashed away in week " +i+ " is " + s2);
Console.WriteLine("The number of acorns squirrel3 stashed away in week " +i+ " is " + s3);
total+=s1+s2+s3;
  
if(i%4==0){
Console.WriteLine("\nThe number of acorns stashed in month "+(i/4)+ " : ");
for(int j=0;j<total ;j++){
Console.Write("*");
  
}
total=0;
Console.WriteLine("\n");
}
  
  
}
  
}
}


Related Solutions

Please code in C# - (C - Sharp) Assignment Description Write out a program that will...
Please code in C# - (C - Sharp) Assignment Description Write out a program that will ask the user for their name; the length and width of a rectangle; and the length of a square. The program will then output the input name; the area and perimeter of a rectangle with the dimensions they input; and the area and perimeter of a square with the length they input. Tasks The program needs to contain the following A comment header containing...
Please code in c# (C-Sharp) Write a program that will ask the user for their name....
Please code in c# (C-Sharp) Write a program that will ask the user for their name. If the user does not input anything, display a warning before continuing. The program will then ask the user whether they want to have an addition, subtraction, multiplication, or division problem. Once the user indicates their choice, the program will display 2 randomly generated numbers from 1 to 9 in a math problem matching the user’s choice. Example: user selects addition, the equation presented...
Write a C program that runs on ocelot for a mini calculator using only the command...
Write a C program that runs on ocelot for a mini calculator using only the command line options. You must use getopt to parse the command line. Usage: minicalc [-a num] [-d num] [-m num] [-s num] [-e] value • The variable value is the starting value. • Value should be validated to be an integer between 1 and 99. Error message and usage shown if not. • -a adds num to value. • -d divides value by num. •...
please write it in printf and scanf please Please write it in c# program please and...
please write it in printf and scanf please Please write it in c# program please and if possible no arrays only loops Loop Introduction Assignment Using the conditions below, write one program that calculates a person’s BMI. Your main() function will call functions 1, 2, and 3. Your program will contain three functions: Function #1: Will ask the user for their weight in pounds and their height in inches. Your function will convert the weight and height into Body Mass...
Please Write C++ PROGRAM : That will write a program that initially prompts the user for...
Please Write C++ PROGRAM : That will write a program that initially prompts the user for a file name. If the file is not found, an error message is output, and the program terminates. Otherwise, the program prints each token in the file, and the number of times it appeared, in a well formatted manner. To accomplish all this, do the following: - Open the file - the user must be prompted and a file name input. DO NOT hardcode...
Please write this program in C++ Write a program that           - a user-defined class Cuboid...
Please write this program in C++ Write a program that           - a user-defined class Cuboid which has the following elements:                    - default constructor (has no parameters)                    - constructor that has 3 parameters (height, length, width)                    - data members                              - height, length, width                    - member functions                              - to set the value of each of the data members - 3 functions                              - to get the value of each of the data members - 3...
Code in C# please. Write a program that will use the greedy algorithm. This program will...
Code in C# please. Write a program that will use the greedy algorithm. This program will ask a user to enter the cost of an item. This program will ask the user to enter the amount the user is paying. This program will return the change after subtracting the item cost by the amount paid. Using the greedy algorithm, the code should check for the type of bill. Example: Cost of item is $15.50 User pays a $20 bill $20...
(Please write in C++) Write a program that reads in a line consisting of a student’s...
(Please write in C++) Write a program that reads in a line consisting of a student’s name, Social Security number, user ID, and password. The program outputs the string in which all the digits of the Social Security number and all the characters in the password are replaced by x. (The Social Security number is in the form 000-00-0000, and the user ID and the password do not contain any spaces.) Your program should not use the operator [ ]...
Please write program in C++ format: Write a program to accept five negative numbers from the...
Please write program in C++ format: Write a program to accept five negative numbers from the user. (1) Find the average of the five numbers and display the answer to the standard output. Keep the answer two decimal points - 5 points (2) Output the numbers in ascending order and display the answer to the standard output. - 5 points
use linux or c program. please provide the answer in details. Write a program that will...
use linux or c program. please provide the answer in details. Write a program that will simulate non - preemptive process scheduling algorithm: First Come – First Serve Your program should input the information necessary for the calculation of average turnaround time including: Time required for a job execution; Arrival time; The output of the program should include: starting and terminating time for each job, turnaround time for each job, average turnaround time. Step 1: generate the input data (totally...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT