



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




Ogana, Alexis Ann M. BSCPE 1- OOP Using System; Namespace MyApplication { Class Program { Static void Main(string[] args) { Console.WriteLine(“YHAMM’S FRESH DRIED FISH”); Console.WriteLine(“ “); Console.WriteLine(“Free Delivery around South City Homes”); Console.WriteLine(“ “); Console.WriteLine(“A1 Boneless Danggit => 1300 (per 1kg)”); Console.WriteLine(“A2 Sweet Pusit => 1300 (per 1kg)”); Console.WriteLine(“A3 Daing Salay => 400 (per 1kg)”); Console.WriteLine(“A4 Dalagang Bukid => 400 (per 1kg)”); Console.WriteLine(“A5 Lupoy => 400 (per 1kg)”); Console.WriteLine(“ “); Console.WriteLine(“What is your order? “); String o = Console.ReadLine(); Switch (o)
Case “A1”: Console.WriteLine(“Your order is A1 Boneless Danggit “); Console.WriteLine(“Your money:”); String a = Console.ReadLine(); If (float.Parse(a) < 1300) { Console.WriteLine(“Money is not sufficient”); } Else { Console.WriteLine(float.Parse(a)-1300+” Change”); Console.WriteLine(“Thank You for supporting our small business!”); } Break; Case “A2”: Console.WriteLine(“Your order is A2 Sweet Pusit”); Console.WriteLine(“Your money:”); String b = Console.ReadLine(); If (float.Parse(b) < 1300) { Console.WriteLine(“Money is not sufficient”); } Else { Console.WriteLine(float.Parse(b)-1300+” Change”); Console.WriteLine(“Thank You for supporting our small business!”); } Break; Case “A3”:
If (float.Parse(e) < 400) { Console.WriteLine(“Money is not sufficient”); } Else { Console.WriteLine(float.Parse(e)-400+” Change”); Console.WriteLine(“Thank You for supporting our small business!”); } Break; Default: Console.WriteLine(“”); Break; } } } }
As a newbie in programming I always get confused about which conditional statement should I use between if-else and switch case statements. After examining the two statements, I found if-else to be easier to comprehend because it appears to be more straightforward to use. You can also use numerous logical operations in the if-else scenario, which you can’t do in the switch case. Switch case condition needs to be constant and you can’t have multiple objects to compare either unlike in if-else you can put a bundle of things in there.