0
Codecoach--paint costs. I keep failing cases 3 and 4. Can anybody help me
I tried to solve Code Coach's paint costs with Java, but I can't get over case 3 and case 4. import java.util.*; public class Program { public static void main(String[] args) { Scanner sc=new Scanner (System.in); int colors=sc.nextInt(); int res=(40+5*colors); int adaos =res*10/100; int res=res+adaos; System.out.println(resi); } }
4 Réponses
+ 1
Cost, rate.. Double values.
In this you have to deal with float or double values.
And convert into Integer by rounding up (with ceil function)...
+ 1
Thank you! It worked. It seems like I didn't read the problem too well.
0
Fine. It helped you... Wel come..
0
import java.util.Scanner ;
public class Program
{
public static void main(String[] args) { Scanner input=new Scanner(System.in);
int colors=input.nextInt();
double cost=colors*5+40.00;
double p=cost*10/100;
System.out.println((int)Math.round(cost+p));
}
}