203k views
0 votes
Write a Bare Bones program that takes as input a value for X and places 4 times the value of X into the value of Z. The value of X should be unchanged at the end of the program. Note that your program should NOT place a value into X to start. You may assume that the value of X has already been set just before your program runs

User Silwar
by
6.9k points

1 Answer

1 vote

Answer:

See the code snippet in the explanation section

Step-by-step explanation:

import java.util.Scanner;

public class BareBonesProgram{

public static void main (String[] args){

Scanner scan = new Scanner(System.in);

System.out.println("Please enter the value of x: ");

int x = scan.nextInt();

int z = 4 * x;

System.out.println("The value of z is: " + z);

System.out.println("The value of x is: " + x);

}

}

User Julio Cezar Silva
by
6.5k points