Begin an empty console application. in c# Design and add a class named dailyMenu
ID: 3713717 • Letter: B
Question
Begin an empty console application. in c#
Design and add a class named dailyMenu that has the following attributes. Please take care to use the proper level of visibility:
string day (name of day of the week)
int date (stores only the day portion of date, e.g. 13)
string entrée
double price
int calories
Write properties for every instance field.
Create a static int variable that you will use to assign the date. You can name it dateAssigner. Initialize the value to 1.
Write a method to assign the current value in the static dateAssigner variable to instance’s date field. Also increment the date.
Write a method of dailyMenu that asks the user to input the day, entrée, price, and calories. Assign these values accordingly.
Write a parameter-less constructor of dailyMenu whose only job is to call the methods you wrote for 5 and 6. When you test your app, you can input whatever values you wish.
Override the ToString Method to output as shown below.
--------------------------------------------------------------------------------------------------------------------------------
In Main, create a 1D array of 5 days that will hold objects of type dailyMenu.
Write a loop to populate the array with a dailyMenu object for each day. Note that when you run your program, you’ll need to input the information for each day. Take a look at the Preston tutorial in D2L labeled “Collections of Instances” for help with this part. NOTE: Please use an Array, NOT a List.
Output the array to the console, printing the entire array, to look something like this. Note: your printout will enable you to verify the functions you create below.
Monday 1
Chicken Nuggets
$3.99
280 Calories
Tuesday 2
Hamburger
$5.99
580 Calories
Wednesday 3
Pizza
$5.99
480 Calories
Write a method in the Main class that accepts the array as an argument. Your function should allow your user to enter an entrée to search for. Provide your user with a printout of any and all days on which this entrée will be served.
Call function you just wrote from main.
Write a method that accepts the array as an argument. Print out the item with the highest caloric value and the lowest caloric value.
Call the function you just wrote from main.
Write one last function that accepts the array as an argument. Ask the user how much money he has budgeted for lunch per day. Print out a list of items that he can afford to purchase and what days (day and date) those items are available.
Call the function that you just wrote from main.
Monday 1
Chicken Nuggets
$3.99
280 Calories
Tuesday 2
Hamburger
$5.99
580 Calories
Wednesday 3
Pizza
$5.99
480 Calories
Explanation / Answer
Hi Dear,
Please find my implementation.
//c# code for daily Menu
using System;
using System.IO;
using System;
class daMenu
{
public static void Main (string[] args)
{
dailyMenu [,] daily_Menu = new dailyMenu[4,5];
for (int aa = 0; aa < 4; aa++)
{
for (int bb = 0; bb< 5; bb++)
{
dailyMenu bout = new dailyMenu ();
//display entree for each day
daily_Menu[aa,bb] = bout;
Console.WriteLine (bout.ToString ());
}
}
dailyMenu bt = new dailyMenu ();
//bt.findLowHighCalorie(daily_Menu);
}
//class daily menu
public class dailyMenu
{
private string dayA;
private int dateA;
public string entreeA {get; private set;}
private double priceA;
private double caloriesA;
static int startDate=1;
static string [] strWeekDays= {"Monday","Tuesday","Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
static string[] entrees = {"Pizza","TANDOORI", "BURGER", "Chicken", "Fish","MUTTOn","EGG HAMLET","Brunswick stew","Cajun cuisine","Macaroni salad","Milk toast","Pancakes" };
static double [] entreeCostPrice= { 5,10,20,30,40,35,76,90,51,67,34};
static int[] calorieVal= { 1009,200,750,896,345,78,234,85,};
public dailyMenu()
{
findDate();
wkDay();
populateRandom();
}
void findDate()
{
dateA = startDate;
startDate++;
if (startDate>5)
{
startDate = 1;
}
}
void populateRandom()
{
Random rk = new Random();
int ranNumr = rk.Next(0,13);
entreeA = entrees [ranNumr];
priceA = entreeCostPrice [ranNumr];
caloriesA = calorieVal [ranNumr];
}
public string wkDay()
{
return strWeekDays [(dateA % 7)-1];
}
//SET & GET DAY
public string DayA
{
get{ return dayA;}
set{dayA = value; }
}
//SET & GET DATE
public int DateA
{
get{ return dateA; }
set{ dateA = value; }
}
//SET AND GET ENTREE FOR THE DAY
public string EntreeA
{
get{ return entreeA; }
set{ entreeA = value; }
}
//SET PRICE FOR THE ENTREE FOR THE DAY
public double myPrice
{
get{ return priceA; }
set{ priceA = value; }
}
//SET & GET FOR CLAORIES OT THE ENTREE
public double myCalories
{
get{ return caloriesA; }
set{ caloriesA = value; }
}
//STRING REPRESENTATION OF DAY, ENTREE, CALORIE,PRICE
public override string ToString ()
{
return string.Format ("WEEK DAY: " + wkDay() + ", Entree: " + entreeA + ", Entree Price: " + priceA + ", Entree Calories: " + caloriesA);
}
//SEARCHES ENTREE
public static void entreeSearch(dailyMenu [,] daily_Menu)
{
Console.WriteLine ("Enter Entree to search");
string getResponse = Console.ReadLine ();
getResponse = getResponse.ToUpper ();
for (int aa = 0; aa < daily_Menu.GetLength(0); aa++)
{
for (int bb = 0; bb < daily_Menu.GetLength(1); bb++)
{
dailyMenu temp = daily_Menu[aa, bb];
if (temp.EntreeA.ToUpper() == getResponse)
{
Console.WriteLine($"Entree {getResponse} is available {daily_Menu[aa, bb].DayA}");
}
}
}
}
public static void findLowHighCalorie(dailyMenu [,] daily_Menu)
{
double highCalorie=0;
double lowcalorie=100;
for (int aa = 0; aa < daily_Menu.GetLength(0); aa++)
{
for (int bb = 0; bb < daily_Menu.GetLength(1); bb++)
{
dailyMenu temp = daily_Menu[aa, bb];
if(temp.myCalories>highCalorie)
highCalorie=temp.myCalories;
else if(temp.myCalories<lowcalorie)
lowcalorie=temp.myCalories;
}
}
Console.WriteLine(" lOW CALORIE Entree :{0} ",lowcalorie);
Console.WriteLine(" high CALORIE Entree :{0} ",highCalorie);
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.