can someone help me compile my code? public class Gpa { public static void main(
ID: 3655013 • Letter: C
Question
can someone help me compile my code? public class Gpa { public static void main( String args[]){ Scanner input = new Scanner(System.in); printgpa(input); } public static void printgpa (Scanner imput){ String name; int test,scores; double average =0.0; System.out.print(" please enter your score"); name= input.next(); test= input.nextInt(); for(int i =0; i<=test; i++) { scores= input.next(); avg= scores; } avg=avg/test; System.out.print(name+"'s grade is" + avg ); } }Explanation / Answer
import java.util.*; public class Calculate { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Num1: "); int num1 = input.nextInt(); System.out.print("Num2: "); int num2 = input.nextInt(); if (num1 > 0 && num2 > 0) { int sum = num1 + num2; System.out.println("Sum= " + sum); } else { System.out.println("Invalid Numbers"); System.out.println("End of program"); } } }
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.