Write an interactive program that is a dialogue between two people. The dialogue should include strings, integers, and double numbers. Make the program more useful by implementing some math calculation. Also, include two types of comments at the proper places
import java.util.Scanner;
public class DialogProgram {
public static void main(String[] args) {
//This scanner read from console string value
Scanner scan=new Scanner(System.in);
//This scanner read from console digits values
Scanner input=new Scanner(System.in);
//Those variables represent name and marks
String name=" ";
int firstMark=0;
int secondMark=0;
int thirdMark=0;
double average=0;
System.out.println("Please provide your last name and press Enter:");
name=scan.nextLine();
System.out.println("Please provide your your mark by Math exam and press Enter:");
firstMark=input.nextInt();
System.out.println("Please provide your your mark by English exam and press Enter:");
secondMark=input.nextInt();
System.out.println("Please provide your your mark by Programing exam and press Enter:");
thirdMark=input.nextInt();
average=(firstMark+secondMark+thirdMark)/3;
scan.close();
input.close();
System.out.println("The student "+name+" has average mark be 3 exam: "+average);
}
}
Comments
Leave a comment