Question

In: Computer Science

[10 marks] (AdditionTable.java) Write a program that displays the following addition table. Notes: You must use...

[10 marks] (AdditionTable.java) Write a program that displays the following addition table. Notes: You must use a nested loop. There are spaces at the beginning of each row. 1 + 1 = 2 1 + 2 = 3 1 + 3 = 4 1 + 4 = 5 1 + 5 = 6 1 + 6 = 7 1 + 7 = 8 1 + 8 = 9 1 + 9 = 10 2 + 2 = 4 2 + 3 = 5 2 + 4 = 6 2 + 5 = 7 2 + 6 = 8 2 + 7 = 9 2 + 8 = 10 2 + 9 = 11 3 + 3 = 6 3 + 4 = 7 3 + 5 = 8 3 + 6 = 9 3 + 7 = 10 3 + 8 = 11 3 + 9 = 12 4 + 4 = 8 4 + 5 = 9 4 + 6 = 10 4 + 7 = 11 4 + 8 = 12 4 + 9 = 13 5 + 5 = 10 5 + 6 = 11 5 + 7 = 12 5 + 8 = 13 5 + 9 = 14 6 + 6 = 12 6 + 7 = 13 6 + 8 = 14 6 + 9 = 15 7 + 7 = 14 7 + 8 = 15 7 + 9 = 16 8 + 8 = 16 8 + 9 = 17 9 + 9 = 18 java programing language

Solutions

Expert Solution

public class AdditionTable {
    public static void main(String[] args) {
        int n = 9;

        for(int i = 1;i<=n;i++){
            for(int j = 1;j<=n;j++){
                System.out.println(i+" + "+j+" = "+(i+j));
            }
        }
    }
}

1 + 1 = 2
1 + 2 = 3
1 + 3 = 4
1 + 4 = 5
1 + 5 = 6
1 + 6 = 7
1 + 7 = 8
1 + 8 = 9
1 + 9 = 10
2 + 1 = 3
2 + 2 = 4
2 + 3 = 5
2 + 4 = 6
2 + 5 = 7
2 + 6 = 8
2 + 7 = 9
2 + 8 = 10
2 + 9 = 11
3 + 1 = 4
3 + 2 = 5
3 + 3 = 6
3 + 4 = 7
3 + 5 = 8
3 + 6 = 9
3 + 7 = 10
3 + 8 = 11
3 + 9 = 12
4 + 1 = 5
4 + 2 = 6
4 + 3 = 7
4 + 4 = 8
4 + 5 = 9
4 + 6 = 10
4 + 7 = 11
4 + 8 = 12
4 + 9 = 13
5 + 1 = 6
5 + 2 = 7
5 + 3 = 8
5 + 4 = 9
5 + 5 = 10
5 + 6 = 11
5 + 7 = 12
5 + 8 = 13
5 + 9 = 14
6 + 1 = 7
6 + 2 = 8
6 + 3 = 9
6 + 4 = 10
6 + 5 = 11
6 + 6 = 12
6 + 7 = 13
6 + 8 = 14
6 + 9 = 15
7 + 1 = 8
7 + 2 = 9
7 + 3 = 10
7 + 4 = 11
7 + 5 = 12
7 + 6 = 13
7 + 7 = 14
7 + 8 = 15
7 + 9 = 16
8 + 1 = 9
8 + 2 = 10
8 + 3 = 11
8 + 4 = 12
8 + 5 = 13
8 + 6 = 14
8 + 7 = 15
8 + 8 = 16
8 + 9 = 17
9 + 1 = 10
9 + 2 = 11
9 + 3 = 12
9 + 4 = 13
9 + 5 = 14
9 + 6 = 15
9 + 7 = 16
9 + 8 = 17
9 + 9 = 18


Related Solutions

powers: Write a program to display the following table with headings and totals. You must use...
powers: Write a program to display the following table with headings and totals. You must use variables to represent all quantities and a for loop for repetition.          x       x^2      x^3          11      121      1331          14      196      2744          17      289      4913          20      400      8000          23      529      12167          26      676      17576          29      841      24389          32      1024     32768          35      1225     42875          38      1444     54872 Totals:  245     6745     201635
Please use Phyton to write a program: Write a program that calculates and displays the total...
Please use Phyton to write a program: Write a program that calculates and displays the total bill at a restaurant for a couple that is dining. The program should collect from the couple, cost of each meal, and the percentage of the final cost that they would like to tip. The sales tax in the state where the restaurant exists is 7.5%. Display to the user, line by line: Total Cost of Both Meals Sales Tax in dollars Tip in...
Write a JAVA program that displays a table of the Celsius temperatures and their Fahrenheit equivalents....
Write a JAVA program that displays a table of the Celsius temperatures and their Fahrenheit equivalents.  The formula for converting a temperature from Celsius to Fahrenheit is F = 9/ 5 C + 32 where F → Fahrenheit temperature C → Celsius temperature.  Allow the user to enter the range of temperatures in Celsius to be converted into Fahrenheit.  Your program must use a loop to display the values of the temperature conversions (see sample output). Sample...
Write a program that displays a temperature conversion table for degrees Celsius and degrees Fahrenheit. The...
Write a program that displays a temperature conversion table for degrees Celsius and degrees Fahrenheit. The table should include rows for all temperatures between 0 and 100 degrees Celsius that are multiples of 10 degrees Celsius. Include appropriate headings on your columns. The formula for converting between degrees Celsius and degrees Fahrenheit can be found on the internet. Python 3
write a python program that inputs 10 integer values from the keyboard and then displays their...
write a python program that inputs 10 integer values from the keyboard and then displays their sum. use for loop
Write a full program that solves the following equation and displays the value for x and...
Write a full program that solves the following equation and displays the value for x and y: 3.4x+50.2y=44.5 2.1x+.55y=5.9
Program must be in C++! Write a program which: Write a program which uses the following...
Program must be in C++! Write a program which: Write a program which uses the following arrays: empID: An array of 7 integers to hold employee identification numbers. The array should be initialized with the following values: 1, 2, 3, 4, 5, 6, 7. Hours: an array of seven integers to hold the number of hours worked by each employee. payRate: an array of seven doubles to hold each employee’s hourly pay rate. Wages: an array of seven doubles to...
Write a program that displays the following patters separately, one below the other in a TextBox.
(Triangles of Asterisks)Write a program that displays the following patters separately, one below the other in a TextBox.Use For..Next loops to generate the patterns. All asterisks (*) should be displayed one at a time by the statement outputTextBox.AppendText(“*”) (this causes the asterisks to display side by side).The statement outputTextBox.AppendText(vbCrLf) can be used to position to the next line, and a statement of the form outputTextBox.AppendText(“ “) can be used to display spaces for the last two patterns. There should be...
Write a program that calculates the average of a four lab marks. It should use the...
Write a program that calculates the average of a four lab marks. It should use the following functions: • void getMarks() should ask the user for a lab marks, store it in a reference parameter variable, and validate it so that lab marks lower than 0 or higher than 100 is not accepted. This function should be called by main once for each of the four lab marks to be entered. • void avgGradeDisp() should calculate and display the average...
Java Program Use for loop 1.) Write a program to display the multiplication table of a...
Java Program Use for loop 1.) Write a program to display the multiplication table of a given integer. Multiplier and number of terms (multiplicand) must be user's input. Sample output: Enter the Multiplier: 5 Enter the number of terms: 3 5x0=0 5x1=5 5x2=10 5x3=15 2 Create a program that will allow the user to input an integer and display the sum of squares from 1 to n. Example, the sum of squares for 10 is as follows: (do not use...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT