I've been trying to run this program I made but I can't seem to get this right. How can I call my PUBLIC VOID in the if-else statement?
public class Program
{
class ExecuteCategory
{
static void Main(string[] args)
{
Console.WriteLine("Input category; Grades for Computing your grade average and MySavings for computing your monthly savings.");
Console.ReadLine();
Console.WriteLine("Input category:");
Console.ReadLine();
/it stops here and won't run the input I called/
bool MySavings, Grades; /above this is the main method/
MySavings = true;
Grades = true;
{
if (MySavings == true)
{
Console.ReadKey(MySavings); /I need to call public void MySavings here/
}
else if (Grades == true)
{
Console.ReadKey(Grades); /I need to call public void Grades here/
}
else
{
Console.WriteLine("Please type a valid category:");
Console.ReadLine();
}
Console.ReadKey();
}
}
class Category
{
public void MySavings ()
{
int Allowance, Savings,Food, Transpo, WFood, WTranspo, WSavings, MFood,MTranspo, MSavings;
Console.WriteLine("Input daily allowance:");
Allowance = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Input daily food expense:");
Food = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Input daily transportation expense:");
Transpo = Convert.ToInt32(Console.ReadLine());
Savings = Allowance - (Food + Transpo);
Console.WriteLine("Daily savings: {0}", Savings);
Console.ReadLine();
WFood = Food * 5;
Console.WriteLine("Weekly Food expense: {0}",WFood);
Console.ReadLine();
WTranspo = Transpo * 5;
Console.WriteLine("Weekly Food expense: {0}", WFood);
Console.ReadLine();
WSavings = Savings * 5;
Console.WriteLine("Weekly Food expense: {0}", WSavings);
Console.ReadLine();
MFood = WFood * 4;
Console.WriteLine("Monthly Food expense: {0}", MFood);
Console.ReadLine();
MTranspo = WTranspo * 4;
Console.WriteLine("Monthly Food expense: {0}", MFood);
Console.ReadLine();
MSavings = WSavings * 4;
Console.WriteLine("Monthly Food expense: {0}", MSavings);
Console.ReadLine();
}
public void Grades()
{
int Filipino, English, Math, Science, History, Average;
Console.WriteLine("Input grade in Filipino:");
Filipino = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Input grade in English:");
English = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Input grade in Math:");
Math = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Input grade in Science:");
Science = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Input grade in History:");
History = Convert.ToInt32(Console.ReadLine());
Average = (Filipino + English + Math + Science + History) / 5;
Console.WriteLine("Average is: {0}", Average);
}
}
}
}
}
it won't run after I input a category. It says that "C:/Program Files/dotnet/dotnet.exe (process 14588) exited with code 0" then it closes.
Aucun commentaire:
Enregistrer un commentaire