#include
using namespace std;
int main()
{
int withdraw;
float balance;
cin>>withdraw;
cin>>balance;
if((withdraw % 5 == 0) && (withdraw + 0.50) < balance)
printf("%.2f",balance - withdraw - 0.50);
else
printf("%0.2f", balance);
return 0;
}
why this code is wrong??
hack48
September 11, 2021, 3:24pm
206
Here is the 2 liners for this having an execution time of 0.00 seconds.
Here is the code:
#include<bits/stdc++.h>
using namespace std;
int main(){
int x; cin>>x;
double y; cin>>y;
if(x%5==0 && y-x-0.5>=0)
cout<<fixed<<setprecision(2)<<double((y-x)-0.5);
else cout<<fixed<<setprecision(2)<<y;
}
Can someone tell me whatās wrong with my code?
import java.util.;
import java.lang. ;
import java.io .*;
/* Name of the class has to be āMainā only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
Scanner s=new Scanner(System.in);
int n=s.nextInt();
double f=s.nextDouble();
if(n%5==0&&n<f)
f-=n+0.5;
System.out.printf(ā%.2fā,f);
}
}
+0.5 cuz 120 - (x+0.5) == 120 - x - 0.5
120 - 30.5
right?
#include<stdio.h>
int main()
{
int x;
float y;
printf("Enter withdraw amounte & balance: ");
scanf("%d %f",&x,&y);
if(x>0 && x<=2000 && y>=0 && y<=2000)
{
if(x%5==0 && y-x-0.5>=0)
{
y=y-x-0.5;
}
printf("Pooja's Bank Balence: %0.4f",y);
}
return 0;
}
// what is problem in this case
#include
#include<bits/stdc++.h>
using namespace std;
int main()
{
int x;
float y,c=0.50;
cin>>x;
cin>>y;
if( x>0 && x<= 2000 && y>=0 && y<=2000){
if(x%5==0){
if((x+c)<y){
// cout<<y-(x+c);
cout << fixed << setprecision(2)<<y-(x+c)<<endl;
}else{
cout<<fixed << setprecision(2)<<y;
}
}else{
cout<<fixed << setprecision(2)<<y;
}
}else{
return 0;
}
// return 0;
}
please define error in this code
you just need the output as shows in output formatā¦no extra string or anything like you did hereā¦
printf("Enter withdraw amounte & balance: ");
printf("Pooja's Bank Balence: %0.4f",y);
i didnāt find oneā¦but it donāt process the correct output if the withdrawal amnt and balance is sameā¦so check that third if block and correct it
#include
#include
using namespace std;
int main() {
int withdraw;
float amount=120.00,x,y;
cin>>withdraw;
if(withdraw % 5 == 0 && amount>=withdraw){
y=amount-withdraw-0.5;
cout<<fixed<<setprecision(2)<<y<<endl;
}
else
cout<<fixed<<setprecision(2)<<float(amount)<<endl;
return 0;
}
I have tried so many custom inputs and it is showing the correct output but when I submit it is showing wrong answer. can someone help
Please tell me what is wrong in this code!!!
#include <stdio.h>
int main()
{
int with;
float inib;
scanf("%d %f", &with,&inib);
if(with > 0 && with <= 2000 && inib>0 && inib<=2000){
if ( (with % 5) == 0 && with < inib)
{
printf("%.2f", (inib - with - 0.5));
}
else
{
printf("%.2f", inib);
}
}
return 0;
}
lh_soul
October 19, 2021, 6:51am
219
#include <stdio.h>
int main(void) {
int wa;
float bal;
scanf("%d%f",&wa,&bal);
if(wa>1 && wa<=2000 && bal>=1 && bal<=2000)
{
if(wa%5==0 && wa<bal)
{
bal=bal-wa-0.5;
}
}
printf("%.2f",bal);
// your code goes here
return 0;
}
Whats worng in this code? HELP
Hello, i am brand new to coding, and to code chef. I am wondering why some code submissions are passing this test when they allow a negative integer for the withdraw amount, or a negative float for the balance amount, and are not checking for the max 2000 limit?
Can anyone tell me why this solution is not getting accepted
#include<bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int a;
float b,c;
cin>>a>>b;
if((a%5==0)&&(b>a+0.50))
{
c= (b- (a)-0.50);
cout<<fixed;
cout<<setprecision(2);
cout <<c;
}
else
{
cout<<fixed;
cout<<setprecision(2);
cout<<b;
}
}
CODECHEF SUCKS
#include
#include
using namespace std;
int main() {
int withdraw;
float balance,total;
cin>>withdraw;
cin>>balance;
if(withdraw>0 && withdraw%5==0){
if(withdraw==balance){
cout<<fixed<<setprecision(2)<<balance;
}
if(withdraw<balance){
total=balance-float(withdraw)-0.50;
cout<<fixed<<setprecision(2)<<total;
}
if(withdraw>balance){
cout<<fixed<<setprecision(2)<<balance;
}
}
else
cout<<fixed<<setprecision(2)<<balance;
return 0;
}
what am I doing wrong?
#include<bits/stdc++.h>
using namespace std;
void solve()
{
int x;float y;
cin>>x>>y;
if(x%5==0)
{
if(x<=y)
{
float ans=(y-.50)-x;
printf("%.2f\n",ans);
}
else
printf("%.2f\n",y);
}
else
printf("%.2f\n",y);
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
solve();
return 0;
}
What is wrong with my code?