Omar Bahaa

Omar Bahaa

  • NA
  • 13
  • 1.1k

How to use inputs inside a "for" loop

Oct 2 2018 7:00 AM
I need to know how to use inputs, i have entered inside a "nested for" loop, to be able to compare them.
 
int topupvalue;
int totaltopupvalue=0;
int topupamount;
string companyname;
int companynumber;
int numberoftopupvalue;
string nameoftopupvalue;
int totaltopupcards =0;
int totalsalespereachtopup =0;
int availtopup=0;
int cardvalue;

Console.WriteLine("Enter number of top up companies");
companynumber =int.Parse(Console.ReadLine());

Console.WriteLine("----------------------------------\n");


for (int i = 0; i < companynumber; i++)
{
Console.WriteLine("Enter company name");
companyname = Console.ReadLine();
Console.WriteLine("----------------------------------\n");


Console.WriteLine("Enter the amount of top up card types");
topupamount = int.Parse(Console.ReadLine());
Console.WriteLine("----------------------------------\n");
for (int d = 0; d < topupamount; d++)
{

Console.WriteLine("Enter name of top up card");
nameoftopupvalue = Console.ReadLine();
Console.WriteLine("------------------------------");

Console.WriteLine("Enter the sale value for the top up card");
topupvalue = int.Parse(Console.ReadLine());

Console.WriteLine("Enter the value for the top up card");
cardvalue = int.Parse(Console.ReadLine());

Console.WriteLine("Enter the total amount of the top up card");
numberoftopupvalue = int.Parse(Console.ReadLine());


Console.WriteLine("-------------------------------------------------");

Console.WriteLine("Enter total card sold for {0}", nameoftopupvalue);
totalsalespereachtopup = int.Parse(Console.ReadLine());

Console.WriteLine("-------------------------------------------------");

Console.WriteLine("Total cards for {0} are: {1} ", nameoftopupvalue, numberoftopupvalue);

Console.WriteLine("-------------------------------------------------");
Console.WriteLine("Total {0} cards sold are: {1}", nameoftopupvalue, totalsalespereachtopup);

Console.WriteLine("-------------------------------------------------");


availtopup = (numberoftopupvalue - totalsalespereachtopup);
Console.WriteLine("Avaliable top up cards for {0} are {1}", nameoftopupvalue, availtopup);

Console.WriteLine("-------------------------------------------------");

totalsalespereachtopup = (totalsalespereachtopup * topupvalue);



totaltopupvalue = (numberoftopupvalue * cardvalue);


Console.WriteLine("-------------------------------------------------");

Console.WriteLine("Total top up value for {0} is {1} ", nameoftopupvalue, totaltopupvalue);
Console.WriteLine("-------------------------------------------------");


totaltopupcards += numberoftopupvalue;

if (totalsalespereachtopup > totaltopupvalue)
{
Console.WriteLine("-------------Something----------------");
}
else if (totalsalespereachtopup < totaltopupvalue)
{
Console.WriteLine("-------------something-------------");
}
Console.WriteLine("Total sales for {0} in pounds are: {1}", nameoftopupvalue, totalsalespereachtopup);
Console.WriteLine("-------------------------------------------------\n");

 
 
 

Answers (2)