Reputation: 329
I'm working on iterations right now, as shown in this page of my textbook:
https://i.sstatic.net/i7vbm.jpg
I have worked out the following code:
package rectangle;
import java.util.Scanner;
public class messin {
public static void main(String[] args){
int number;
Scanner scanner = new Scanner(System.in);
number = scanner.nextInt();
double newstuff = Math.sqrt(number*number+number*number);
System.out.format("%10.3f%n", newstuff);
}
}
This is suppose to be a rectangle driver that uses the equation c = sqrt(a^2+b^2). As you can see I am not very far, but I will update as I get further. Thanks for the help and patients with the edits.
Upvotes: 2
Views: 2361
Reputation: 199
You can use Scanner from java.util package to get the input from user.
Scanner scan = new Scanner(System.in);
int num = scan.nextInt();
for (int i = 1; i < num; i++) {
System.out.printf("%d\t", i);
}
System.out.println();
for (int i1 = 1; i1 < num; i1++) {
for (int j = 1; j <= i1; j++) {
System.out.printf("%d\t", i1 * j);
}
System.out.println();
}
Upvotes: 3