jeudi 18 mars 2021

Can anyone help me with this in c#? [closed]

I'm new to programming so if you need more info on what im asking just tell me. When i run this code and i type "y" it works just fine but whenever I type anything other than "y" then it doesnt do what i want the program to do.

else if (cash == 5){
    Console.WriteLine("Here is your ticket! Do you wish to leave a tip? (y/n)");
    string tip = (Console.ReadLine());
    if (tip == "y"){
        Console.Write("Write your tip here: ");
        int tipnr = Convert.ToInt32(Console.ReadLine());
        Console.WriteLine("A " + tipnr + " dollar tip? Thank you so much!");}
    else{
        Console.WriteLine("Here is your ticket.");}

Aucun commentaire:

Enregistrer un commentaire