Program needs to be written in C#. Thank you There is a fish day care center cal
ID: 3875754 • Letter: P
Question
Program needs to be written in C#. Thank you
There is a fish day care center called Fish-O-Rama. They need a console app that will calculate the daily fish care fee based on a fish's size. The program must accept the following from the user: Customer Name, Fish Name, Fish Species, and Fish Length (in inches). Once the data has been entered, the program should display all of the entered data, as well as the daily fish care fee, calculated as follows: $7 for fish under 10", $12 for fish 10" to 20" inclusive, $16 for fish greater than 20" and up to 30", and $20 for fish greater than 30". USE ONLY NAMED CONSTANTS, FOR ALL FISH SIZES AND FEES. In your output, demonstrate that it calculates the correct fee for several (at least three) different sizes of fish.
Explanation / Answer
using System;
//Named Constants using enumerations
public enum Size { Small, SmallMedium, BigMedium, Big};
public enum Fees { low =7, medium = 12, higher = 16, highest = 20};
public class Test
{
public static void Main()
{
Console.WriteLine("Enter Customer Name : ");
string customerName = Console.ReadLine();
Console.WriteLine("Enter Fish Name : ");
string fishName = Console.ReadLine();
Console.WriteLine("Enter Fish Species : ");
string fishSpecies = Console.ReadLine();
Console.WriteLine("Enter Fish Length : ");
int fishLength = Convert.ToInt32(Console.ReadLine());
Size fishSize = Size.Small;
Fees fishFees = Fees.low;
if(fishLength < 10)
{
fishSize = Size.Small;
fishFees = Fees.low;
}
else if(fishLength >= 10 && fishLength <= 20)
{
fishSize = Size.SmallMedium;
fishFees = Fees.medium;
}
else if(fishLength > 20 && fishLength <= 30)
{
fishSize = Size.BigMedium;
fishFees = Fees.higher;
}
else if(fishLength > 30)
{
fishSize = Size.Big;
fishFees = Fees.highest;
}
int ffees = (int)fishFees;
Console.WriteLine("Customer Name : "+ customerName);
Console.WriteLine("Fish Name : "+fishName);
Console.WriteLine("Fish Species : "+fishSpecies);
Console.WriteLine("Fish Length : "+fishLength);
Console.WriteLine("The Size of fish : "+ fishSize);
Console.WriteLine("The Fees of fish : "+ ffees);
}
}
Output:
Enter Customer Name :John
Enter Fish Name :Tuna
Enter Fish Species :Species1
Enter Fish Length : 15
Customer Name : John
Fish Name : Tuna
Fish Species : Species1
Fish Length : 15
The Size of fish : SmallMedium
The Fees of fish : 12
Enter Customer Name :Cathy
Enter Fish Name :Sangara
Enter Fish Species :Species4
Enter Fish Length :22
Customer Name : Cathy
Fish Name : Sangara
Fish Species : Species4
Fish Length : 22
The Size of fish : BigMedium
The Fees of fish : 16
Enter Customer Name :timothy
Enter Fish Name :Malli
Enter Fish Species :Species8
Enter Fish Length :35
Customer Name : Timothy
Fish Name : Malli
Fish Species : Species8
Fish Length : 35
The Size of fish : Big
The Fees of fish : 20
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.