Title
This is objects
public class Cool {
String Height = "very tall";
int age = 16;
}
public class Main {
public static void main(String[] args) {
Cool myBeans = new Cool();
System.out.println("My height is " + myBeans.Height);
System.out.println("My age is " + myBeans.age);
}
}
Main.main(null)
import java.util.Scanner;
public class GuessingGame
{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
double a = (1 + Math.random() * 100);
int b = ((int) Math.floor(a));
Integer c = 0;
System.out.println("What is the number?");
c = scanner.nextInt();
while (!c.equals(b)) {
System.out.println( c + " was not the number");
if (c > b) {
System.out.println("lower\n");
}
if (c < b) {
System.out.println("higher\n");
}
c = scanner.nextInt();
}
if (c == b) {
System.out.println("You guessed it! The number was " + b);
}
}
}