Invictus Genius
Elite
change = cash – total;Pakilagay din kung ano error para madali
total = quantity * 40,000.00;Pakilagay din kung ano error para madali
Console.Write("The Total Amount is: {0}", Total);
Salamat lodsG-Swan, integer dapat input mo para walang error, sa sunod naman yung 'Total' gawin mong 'total' case sensitive yang language mo, yung 'if else' dapat 'else if', yung 'start' dapat 'Start'.
using System;
public class Program
{
public static void Main()
{
string input;
int qty;
double total, cash, change;
string itemName;
float itemPrice;
do
{
Console.WriteLine("Available Items:\n");
Console.WriteLine("[A] Laptop");
Console.WriteLine("[B] Tablet");
Console.Write("Choice: ");
input = Console.ReadLine();
itemName = "";
itemPrice = 0;
if(input == "A" || input == "a")
{
itemName = "Laptop";
itemPrice = 40000;
}
else if(input == "B" || input == "b")
{
itemName = "Tablet";
itemPrice = 20000;
}
else if (input == "0")
{
return;
}
else
{
Console.WriteLine("Invalid input... Try again");
}
if(itemName != "" && itemPrice != 0)
{
Console.WriteLine("The " + itemName + " price is P" + itemPrice);
Console.Write("Enter quantity: ");
qty = int.Parse(Console.ReadLine());
total = qty * itemPrice;
Console.WriteLine("Total Amount: " + total);
Console.Write("Enter your cash: ");
cash = float.Parse(Console.ReadLine());
if(cash >= total)
{
change = cash - total;
Console.WriteLine("\n\nYour change: " + change);
Console.WriteLine("Thank you for shopping!\n\n\n\n\n");
}
else
{
Console.WriteLine("Insufficient Amount. Please try again...\n\n\n\n\n");
}
}
} while(input != "0");
}
}
salamat sirC#:using System; public class Program { public static void Main() { string input; int qty; double total, cash, change; string itemName; float itemPrice; do { Console.WriteLine("Available Items:\n"); Console.WriteLine("[A] Laptop"); Console.WriteLine("[B] Tablet"); Console.Write("Choice: "); input = Console.ReadLine(); itemName = ""; itemPrice = 0; if(input == "A" || input == "a") { itemName = "Laptop"; itemPrice = 40000; } else if(input == "B" || input == "b") { itemName = "Tablet"; itemPrice = 20000; } else if (input == "0") { return; } else { Console.WriteLine("Invalid input... Try again"); } if(itemName != "" && itemPrice != 0) { Console.WriteLine("The " + itemName + " price is P" + itemPrice); Console.Write("Enter quantity: "); qty = int.Parse(Console.ReadLine()); total = qty * itemPrice; Console.WriteLine("Total Amount: " + total); Console.Write("Enter your cash: "); cash = float.Parse(Console.ReadLine()); if(cash >= total) { change = cash - total; Console.WriteLine("\n\nYour change: " + change); Console.WriteLine("Thank you for shopping!\n\n\n\n\n"); } else { Console.WriteLine("Insufficient Amount. Please try again...\n\n\n\n\n"); } } } while(input != "0"); } }