🔒 Closed C# pa correction sa code

Status
Not open for further replies.
Screenshot_20201106-111344_1.webp

Lods yung mga error ano yung kulang jan?

Paki lagay naman ng code sa mga mali ko. Thanks in advance
 
G-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'.
 
C#:
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");
    }
}
 
string month;
int date;

Console.Write("Enter your birthmonth: ");
month = Console.ReadLine();
Console.Write("Enter your birth date: ");
date = int.Parse(Console.ReadLine());


if ((month.ToLower == september) || (month.ToLower == october)) - “september”
“october”;

ito din boss nag error
The name 'September' 'october' does not exist in the current context



if ((date >= 24) || (date <= 30))
{
Console.WriteLine("Your zodiac sign is LIBRA");
}
else if ((date >= 1) || (date <= 23))
{
Console.WriteLine("Your zodiac sign is LIBRA");
}

else
{
Console.WriteLine("Invalid Input");
Console.WriteLine("You are an alien!");
}
 
C#:
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 sir
 
Status
Not open for further replies.

About this Thread

  • 12
    Replies
  • 625
    Views
  • 6
    Participants
Last reply from:
Invictus Genius

Online now

Members online
935
Guests online
3,159
Total visitors
4,094

Forum statistics

Threads
2,276,136
Posts
28,967,815
Members
1,231,128
Latest member
Dedegodskga
Back
Top