0

Can you help me in altering my formula so that the result don't extend after 5

import java.util.Scanner; public class Program { public static void main(String[] args) { int a,b,c,d,e,n; float f; Scanner scan=new Scanner(System.in); a=scan.nextInt(); System.out.println("5 rate :" +a); b=scan.nextInt(); System.out.println("4 rate :" +b); c=scan.nextInt(); System.out.println("3 rate :" +c); d=scan.nextInt(); System.out.println("2 rate :" +d); e=scan.nextInt(); System.out.println("1 rate :" +e); f=scan.nextInt(); System.out.println("total :" +f); n=scan.nextInt(); System.out.println("full:" +n); System.out.println("end:" +(5+(a+(n-(f+a)))+4*b+3*c+2*d+1*e)/f); } }

31st Aug 2020, 6:18 AM
Optimus Prime
Optimus Prime - avatar
2 Answers
+ 1
An "if else" Statement should do the job.
31st Aug 2020, 6:21 AM
Arsenic
Arsenic - avatar
0
Where to apply it
31st Aug 2020, 6:22 AM
Optimus Prime
Optimus Prime - avatar