Answer to Question #195618 in Java | JSP | JSF for William

Question #195618

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


1
Expert's answer
2021-05-20T00:30:57-0400
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);


	}



}


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS