Back
import java.util.*;
public class example1 {
/**
* @param args
*/
public static void main(String[] args)
{
//Variable declarations for input and calculations
int a, b, c, d;
//Input
System.out.println("Example 1: \n");
System.out.println("Enter a value for 'a': ");
/*readInt is another method, that will return an int
and it will not take in any parameters*/
a = readInt();
System.out.println("Enter a value for 'b': ");
b = readInt();
//Calculations
//Should c and d be the same?
c = ( ( a + b - 1) * 2) /4;
d = a + b - 1 * 2 / 4;
//Output
System.out.println("c = " + c);
System.out.println("d = " + d);
}
public static int readInt()
{
Scanner sc = new Scanner(System.in);
int x = sc.nextInt();
return x;
}
}
Top |