Код: Выделить всё
//evaluate subtotals to results
if (subTotalOne == subTotalTwo)
{
Console.WriteLine("=");
}
else if (subTotalOne < subTotalTwo)
{
Console.WriteLine("");
}
Любая помощь будет оценена по достоинству. Я прочитал форумы здесь и видел множество похожих вопросов, но мое понимание еще недостаточно хорошо, чтобы отобразить решения моей проблемы, которые я видел.
Полный код приложения:
Код: Выделить всё
using System;
{
class Program
{
static void Main(string[] args)
{
Код: Выделить всё
Console.WriteLine("Compare Grocery Stores "); //Alert user to purpose of program with title
Console.WriteLine("\n");//line break
// Store 1
Console.WriteLine("Enter the name of the first store for comparison: ");//storeName 1
String storeOne = Console.ReadLine();//ToLower for eval
//store 1, first item
Console.WriteLine("Name of First product purchased at " + storeOne + ": ");//ask item
String purchaseOne = Console.ReadLine();//collect item
Console.WriteLine("Price paid for first purchased at " + storeOne + ": ");//ask 1st price
Double price1A = Double.Parse(Console.ReadLine());//collect 1st price
//store 1, second item, repeat process -- this ought to be a method or a function
Console.WriteLine("Name of second product purchased at " + storeOne + ": ");//ask item
String purchaseTwo = Console.ReadLine();//collect Item
Console.WriteLine("Price paid for second purchased at " + storeOne + ": ");//Ask Item Price
Double price1B = Double.Parse(Console.ReadLine());//Collect Item Price
Console.WriteLine("\n");
// Store 2, repeat process -- this ought to be a method or a function
Console.WriteLine("Enter the name of the second store for comparison: ");//Store name 1
String storeTwo = Console.ReadLine();// To Evals entry, we ToLower to set to lower case
//store 2
Console.WriteLine("Price paid for " + purchaseOne + " at " + storeTwo + ": ");//ask 1st price
Double price2A = Double.Parse(Console.ReadLine());//collect 1st price
//store 2, second item
Console.WriteLine("Price paid for " + purchaseTwo + " at " + storeTwo + ": ");//Ask Item Price
Double price2B = Double.Parse(Console.ReadLine());//Collect Item Price
Console.WriteLine("\n");
// Results go here
//Store one totals
Console.WriteLine("************ " + storeOne + " ************");
Console.WriteLine(purchaseOne + ": $" + price1A);
Console.WriteLine(purchaseTwo + ": $" + price1B);
Console.WriteLine("\n \n");
// store two totals
Console.WriteLine("************ " + storeTwo + " ************");
// Result A: Where to shop
Console.WriteLine(purchaseOne + ": $" + price2A);
Console.WriteLine(purchaseTwo + ": $" + price2B);
Console.WriteLine("\n \n");
Console.WriteLine("************ After Price Comparison ************");
//merge subtotals
Double subTotalOne = (price1A + price1B);
Double subTotalTwo = (price2A + price2B);
//evaluate subtotals to results
if (subTotalOne == subTotalTwo)
{
Console.WriteLine("=");
}
else if (subTotalOne < subTotalTwo)
{
Console.WriteLine("");
}
//keeps the console open
Console.Read();
}
}
Подробнее здесь: https://stackoverflow.com/questions/192 ... d-new-obje
Мобильная версия