I'm new to programming. I plan to make this get executed in another class called Class ExecuteCategory where the main method is where I would like to make an if-else statement where it can make the user input the category of either MySavings or Grade and it will show the one under the category.
I can't seem to make the if-else statement in the main method because it gets a lot of errors. Can anyone send me an example of what I can do?
using System;
namespace HandsOn3
{
public class Program
{
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();
Console.ReadKey();
}
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);
Console.ReadKey();
}
}
class ExecuteCategory
{
static void Main(string[] args)
Aucun commentaire:
Enregistrer un commentaire