Answer to Question #123310 in Java | JSP | JSF for John Green

Question #123310
write a program in Java code that assigns a value entered by the user to a variable. The program then increases the value of the variable by 10 and outputs the result. Don’t forget to include the comments at the top of your program.


//***********************************************
// ASSIGNMENT #: 2
// PROBLEM #: 1
// PROGRAM-NAME: AddTen
//**********************************************
class AddTen {
public static void main(String[] args){
//Declare variables as integers, initialize variables with values
int myNumber = 5;
int myAnswer = 0;
//Do the calculation
myAnswer = myNumber + 10
1
Expert's answer
2020-06-23T03:14:01-0400
import java.util.Scanner;

//*********************************************** 

// ASSIGNMENT #: 2

// PROBLEM #: 1

// PROGRAM-NAME: AddTen

//***********************************************

class AddTen {

	/**

	 * The start point of the program

	 * @param args

	 */

	public static void main(String[] args){

		//The Scanner class is used to get the user input 

		Scanner keyBoard =new Scanner(System.in);

		//Declare variables as integers, initialize variables with values

		System.out.print("Enter integer value: ");

		//read the value from the user

		int myNumber = keyBoard.nextInt();

		//Do the calculation

		//increase the value of the variable by 10  

		int myAnswer = myNumber + 10;

		//output the result. 

		System.out.println("Result: "+myAnswer);

		//close Scanner

		keyBoard.close();

	}

}

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