Question

1. Write a Java program to create the following grid of numbers, using for statements:
1 2 3 4 5
2 3 4 5 6
3 4 5 6 7
4 5 6 7 8
5 6 7 8 9

2. Use nested for loops statements to generate the following output.
Sample output:
Do you want to start(Y/N): y
Enter an integer (1 - 9) 12
ERROR! Should be positive. REENTER: 4
1
22
333
4444
Do you want to continue(Y/N): y
Enter an integer (1 - 9) 6
1
22
333
4444
55555
666666
Do you want to continue(Y/N): y
Enter an integer (1 - 9) 3
1
22
333
Do you want to continue(Y/N): n

3. Write a Java program that prompts for integers and displays them in binary.
Sample output:
Do you want to start(Y/N): y
Enter an integer and I will convert it to binary code: 16
You entered 16.
16 in binary is 10000.
Do you want to continue(Y/N): y
Enter an integer and I will convert it to binary code: 123
You entered 123.
123 in binary is 1111011.
Do you want to continue(Y/N): y
Enter an integer and I will convert it to binary code: 359
You entered 359.
359 in binary is 101100111.
Do you want to continue(Y/N): y
Enter an integer and I will convert it to binary code: 1024
You entered 1024.
1024 in binary is 10000000000.
Do you want to continue(Y/N): n

Solution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

1.
public class GridPrint {

public static void main(String[] args)
{
for(int i = 1; i <= 5; i++)
{
for(int j = i; j < i+5; j++)
System.out.print(j + " ");
System.out.println();
}
}
}...

This is only a preview of the solution. Please use the purchase button to see the entire solution

Related Homework Solutions

Multiplication Table in Java
Homework Solution
$40.00
Java
Programming
Codes
Algorithms
Computer Science
Statements
Variables
Loops
Rows
Columns
Input
Output
Integers
Strings
Multiplication
Tables
Operations
Conditions
From BS Tree to AVL Tree in Java
Homework Solution
$20.00
Java
Programming
Codes
Algorithms
Binary Search Tree
AVL Tree
Search Operation
Logarithmic Time
Rebalancing
Loops
Statements
Variables
Successors
Ancestors
Parents
Nodes
Edges
Boolean Values
Data Structures
Money Problems in Java
Homework Solution
$20.00
Java
Programming
Codes
Algorithms
Money
Dimes
Nickels
Pennies
Input
Output
Integers
Statements
Variables
Accounting
Recursion Methods
Finance
Java Program For Restaurants
Homework Solution
$18.00
Java
Restaurants
Computer Science
Programming
Tips
Variables
Functions
Dollar Amounts
Functions
Input
Output
Statements
Multiplication
Bills
Percentage
Division
NumberFormat Class
Java Programming: Stack & Queue
Homework Solution
$40.00
Programming
Java
Coding
Computer Science
Data Sets
Stack
Queue
Matrix
Circular Array
Algorithm
Duplicates
Sequences
Test Files
Random Functions
Mathematicians
Josephus Problem
Statements
Variables
Get help from a qualified tutor
Live Chats