Question: import java.util.Scanner; public class NewClass3 { public static void
ID: 3545823 • Letter: Q
Question
Question:
import java.util.Scanner;
public class NewClass3
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
float disloan;
int Loan = 16000;
System.out.print("Enter your CGPA :");
float CGPA = sc.nextFloat();
if(CGPA==4.0)
disloan=0;
else if(CGPA>=3.00&&CGPA<=3.99)
disloan=Loan*80/100;
else if(CGPA>=2.00&&CGPA<=2.99)
disloan=Loan*40/100;
else if(CGPA<=1.99)
disloan=Loan;
System.out.println("Your Loan after discount : "+ disloan);
}
}
Please help check where my wrong, and solve it.
Give me full code also comment in wrong line.
Thank you
Explanation / Answer
Hiee
Your code is near perfect ,,
Small changes :
1) float disloan; should be initialized ... i.e float disloan=0;
2) //Optional
public class NewClass3 .. here public is used when your file name is silmilar to class name ..
Cheers have fun :)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.