using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CodeChef_ATM
{
class Program
{
static void Main(string[] args)
{
/* Made by Stefan Stojanovic [Alisp]
using .NET Visual Studio Community 2019 16.8.1*/
// User input for bank account and withdrawal amount
Console.WriteLine("Input how much money you have in the bank acount and how much you would like to withdraw. The Bank takes 0.5$ as tax.");
Console.WriteLine("Example: '200' '99'");
Console.Write("(Account)(Withdrawal): ");
string[] userInput = Console.ReadLine().Split(' ');
// Current account balance.
double trueaccount = Convert.ToDouble(userInput[0]);
double accounttracker = trueaccount;
// Withdrawal amount.
double truewithdraw = Convert.ToDouble(userInput[1]);
// Check if multiple of 5.
if (truewithdraw % 5 == 0)
{
Console.WriteLine("Withdrawal must me a multiple of 5. Example: 54,36,29...");
Console.WriteLine("Try Again.");
Console.ReadLine();
return;
}
// Check if there is enough available money.
if (truewithdraw + 0.5 > trueaccount)
{
Console.WriteLine("You can't withdraw more than available money from the account.");
Console.WriteLine("Try Again.");
Console.ReadLine();
return;
}
// Calculating the withdrawal.
trueaccount -= truewithdraw;
trueaccount -= 0.50;
// Result.
Console.WriteLine($"The amount of money you had in the account: {accounttracker}$");
Console.WriteLine($"The amount of money you have currently: {trueaccount}$");
// End.
Console.ReadLine();
}
}
}
What is wrong with this code?
Am I making some silly mistake? Let me know soon! #include #include
using namespace std;
int main()
{
int x;
float y;
cin>>x>>y;
if((x>0&&x<=2000)&&(y>=0&&y<=2000))
{if((x%5==0) && (y>x+0.5))
{
y=y-x-0.50;
cout<<setprecision(2)<<fixed;
cout<<y;
}
else
{
cout<<setprecision(2)<<fixed;
cout<<y;
}
}
return 0;
}
I have been getting an error in this code every time I run it. Is something wrong with the code? I think I might be facing problems using the custom input maybe.
x = int(input("The amount of cash to be withdrawn: "))
y = int(input("Initial account balance: "))
bank_charges = 0.50
if (x%5 == 0):
y = y - x - bank_charges
print(y)
else:
print(y)
Can anyone help me diagnose the problem here? I know I should be specific with what error I am getting but I change a few things and try again and the error lines changes.
class Codechef
{
public static void main (String[] args)
{
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
double balance = scanner.nextDouble();
double result;
if (n % 5 == 0 && n < balance){ result =(balance - n) - 0.5;
System.out.println(result);}
if (n % 5 != 0 && n+0.5<= balance){
System.out.println(balance);}
else if (n>balance || n+0.5>balance){
System.out.println("Insufficient transaction");}