this is the program that i need to do
You are required to write a command line program in Java that declares three numbers.
Write a method called calc() that takes in the three numbers as parameters. Inside this
method, you must add the first two numbers together and divide the answer by the
third. The value of the sum must be returned. Write another method called display()
that prints the following to the screen:
******************************************
* *
* This is a simple program *
* that performs a mathematical *
* calculation. The answer is: *
* [answer] *
******************************************
so far i made this.
import java.util.Scanner;
public class assignmentB
{
public int calc(){
int number1;
int number2;
int number3;
int sum;
Scanner scan=new Scanner(System.in);
System.out.println("Please enter 1st number: ");
number1 = scan.nextInt();
System.out.println("Please enter 2nd number: ");
number2 = scan.nextInt();
System.out.println("Divide the sum of the two numbers by: ");
number3 = scan.nextInt();
sum = (number1 + number2)/ number3;
return sum;
}
public String display(){
System.out.println("****************************** ***");
System.out.println("* *");
System.out.println("* This is a simple program *");
System.out.println("* that performs a mathematical *");
System.out.println("* calculation. The answer is: *");
System.out.println("* "+ sum +" *");
System.out.println("* *");
System.out.println("****************************** ***");
}
}
can anyone fix this for me? so it will work as state above.