Question
I need help for how to write a single program that prompts and reads: the users first and last name, three integer scores, then calculates
I need help for how to write a single program that prompts and reads:
- the users first and last name,
- three integer scores, then calculates the total and average, and
- outputs the name, three scores, total, and average properly formatted.
and have the output formatted using the printf() method. and "please submit .java files that are ready to compile and run using Oracle JDK 1.7 or above. Please make sure that the java files can compile on command line without any IDE (Integrated Development Environment) tools such as Eclipse, NetBeans, etc."
This is my first programming class so I don't really know what I'm doing, but this is what I have so far and it's riddled with errors...
public class JavaApplication1 { import java.util.Scanner;} public class Username { public static void main(String[] args); { //Initialise Variables String FirstName; String LastName; String Result;
Scanner input = new Scanner(System.in);
//prompts the user to enter firstname System.out.print("Please Enter First Name: "); FirstName=input.next();
//prompts the user to enter lastname System.out.print("Please Enter Last Name: "); LastName=input.next(); import java.util.Scanner;
public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Input the first number: "); double x = in.nextDouble(); System.out.print("Input the second number: "); double y = in.nextDouble(); System.out.print("Input the third number: "); double z = in.nextDouble(); System.out.print("The average value is " + average(x, y, z)+" " ); }
public static double average(double x, double y, double z) { return (x + y + z) / 3; } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started