i am doing some machine program that our teacher. told us to do, i have figured out how to solve it, the first output is correct but the second one gives me an answer of 3.10752688172043, and the answer should be 3.75268817.
here is my code...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BeefPrice
{
class Beef
{
static void Main(string[] args)
{
Console.WriteLine("*********WELCOME USER**********");
double packageA ;
double packageB;
double percent = 0.01;
double ress;
double resultA;
double result;
double resultB;
double result1;
Console.WriteLine("Price for beef package A: ");
packageA = double.Parse(Console.ReadLine());
Console.WriteLine("Percent for lean package A: ");
ress = double.Parse(Console.ReadLine());
resultA = ress * percent;
result = packageA / resultA ;
Console.WriteLine("Price for beef package B: ");
packageB = double.Parse(Console.ReadLine ());
Console.WriteLine("Percent for lean package B: ");
ress = double.Parse(Console.ReadLine());
resultB = ress * percent;
result1 = packageA / resultB;
Console.WriteLine("The price of package A: " + result );
Console.WriteLine("The price of package B: " + result1 );
if (result < result1 )
{
Console.WriteLine("The best choice is package A");
}
else
{
Console.WriteLine ("The best choice is package B");
}
if (result == result1 )
{
Console.WriteLine("They have the same value");
}
Console.ReadKey();
}
}
}
the program runs like this
price for package A:
2.89
Percent for package A:
85
price for package A:
3.49
Percent for package A:
93
The price of package A: 3.4
The price of package B: 3.75268817
The best choice is package A