The else Clause - I need help.. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

The else Clause - I need help..

The else Clause You are creating a mobile payment application. Write a program to take a user payment and outstanding balance as input. If the balance is greater or equal to payment, the program should output "Completed", otherwise the program should output "Insufficient funds". Sample Input 1570 14368.12 Sample Output Completed The else block executes when the condition in the if statement evaluates to false.using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SoloLearn { class Program { static void Main(string[] args) { double payment = Convert.ToDouble(Console.ReadLine()); double balance = Convert.ToDouble(Console.ReadLine()); //your code goes here if(balance > payment) { Console.WriteLine("Completed"); } else if (balance < payment) { Console.WriteLine("Insufficient funds"); } } } }

16th Dec 2021, 10:19 PM
Chris
Chris - avatar
3 Answers
+ 3
Heya, with what exactly do you need help? =)
16th Dec 2021, 10:26 PM
Krysto Foxik 🐥
Krysto Foxik 🐥 - avatar
+ 2
The if condition should use ">=" instead of ">". And instead of else if you could just use else.
16th Dec 2021, 10:44 PM
Simon Sauter
Simon Sauter - avatar
0
Simon, I change the if condition to >= like you recommend but I kept the else if part. The code passed.
17th Dec 2021, 4:19 AM
Chris
Chris - avatar