Create a table to represent your table visual basics Module.
This is the Question to be anwsered Case 1: What will be the value of x after the following loop is executed:
x = 0
For i = 1 To 2
For j = 1 To 3
x = x * i * j
Next j
Next i
NOTE:
This is an example of what your anwser should look like:
x |
i |
j |
NOTES |
0 |
x is initialized to 0 |
||
x = 0*1*1, the new value for x is 0 |
1 |
1 |
First we start with the outer loop (for I ) and continue with inner loop (for J ). |
x = 0*1*2, the new value for x is 0 |
1 |
2 |
Still in the inner loop when J becomes 2, note I is 1 |
x = 0*1*3, the new value for x is 0 |
1 |
3 |
Still in the inner loop when J becomes 3, note I is 1 |
x = 0*2*1, the new value for x is 0 |
2 |
1 |
Here program continues with the outer loop, where I is 2 and moves to inner loop where J is 1 |
x = 0*2*2, the new value for x is 0 |
2 |
2 |
Program continues with the inner loop when J becomes 2, note I is 2 |
x = 0*2*3, the new value for x is 0 |
2 |
3 |
Program continues with the inner loop when J becomes 3, note I is 2 |
X = 0 |
Is the final value for x when both loops are completed |
Answer :
x |
i |
j |
NOTES |
0 |
x is initialized to 0 |
||
x = 0*1*1, the new value for x is 0 |
1 |
1 |
First we start with the outer loop (for I ) and continue with inner loop (for J ). |
x = 0*1*2, the new value for x is 0 |
1 |
2 |
Still in the inner loop when J becomes 2, note I is 1 |
x = 0*1*3, the new value for x is 0 |
1 |
3 |
Still in the inner loop when J becomes 3, note I is 1 |
x = 0*2*1, the new value for x is 0 |
2 |
1 |
Here program continues with the outer loop, where I is 2 and moves to inner loop where J is 1 |
x = 0*2*2, the new value for x is 0 |
2 |
2 |
Program continues with the inner loop when J becomes 2, note I is 2 |
x = 0*2*3, the new value for x is 0 |
2 |
3 |
Program continues with the inner loop when J becomes 3, note I is 2 |
X = 0 |
Is the final value for x when both loops are completed |
Create a table to represent your table visual basics Module. Open a blank Word or Text...
Open a new file in your text editor, and start a class that will demonstrate a working two-dimensional array: import java.util.Scanner; class TwoDimensionalArrayDemo { public static void main(String[] args) { 2. Declare a three-by-three array of integers. By default, the elements will all be initialized to 0. int[][] count = new int[3][3]; 3. Declare a Scanner object for input, variables to hold a row and column, and a constant that can be used to indicate when the user wants to...
Piggy back on the programming project one you completed in module 3. You will use some of those concepts here again. We will be building this project inside out, start individual quiz and use a for loop to repeat it three times for three students. In this program you will be required to write a python program that generates math quizzes for students in second grade. Your program should do the following Ask the student for their name Provide 3...
Task 5.2 Numerical Analysis Using Nested Loops (13 pts) Consider the following program: void setup() { //Read a positive integer from the user //Your code starts here } Complete this program such that it calculates all prime numbers between 1 and the value that is assigned to variable num and outputs them on the screen. A prime number is a positive integer that has no other factors other than itself and 1. You should use a nested loop, i.e., write...
A) Rewrite the following pseudocode segment in C++ using the loop structures (for and while). Assume that all the variables are declared and initialized. k-G+ 13)/27 loop: if k> 10 then goto out k=k+1 i=3"k-1 goto loop I out: B) Rewrite the following code segment in C++ using the multiple-selection (switch and if-else) statements. Assume that all the variables are declared and initialized. if((k 1) || (k 2))j-2 k-1 if ((k 3) || ( ks))j - 3.k+1 if (k 4)j-4k-1...
In this assignment, you will write a program in C++ which uses files and nested loops to create a file from the quiz grades entered by the user, then reads the grades from the file and calculates each student’s average grade and the average quiz grade for the class. Each student takes 6 quizzes (unknown number of students). Use a nested loop to write each student’s quiz grades to a file. Then read the data from the file in order...
1. Create a Python script file called Assignment_Ch06-02_yourLastName.py. (Replace yourLastName with your last name.) 2. Write a Python program that prompts the user for a sentence, then replaces all the vowels in the sentence with an asterisk: '*' Your program should use/call your isVowel function from Assignment_Ch06-01. You can put the isVowel() function in a separate .py file, without the rest of the Ch06-01 code, and then import it. 6-01 CODE: def isVowel(x): if x in "aeiouyAEIOUY": return True else:...
VISUAL BASIC- create a program for managing a "To Do" list. The program will need to read and update a text file named ToDoList.txt. The record structure of the file must be: 1) sort order, 2) task name and 3) desired completion date. When the program starts, it should read the contents file into a structure. The information should then be displayed in a data grid view. The data should be initially sorted by the sort order value. Afterwards, the...
Java Submit a program in a .java file. The program should print a multiplication table for the numbers 1-9. This requires a nested for loop. The outer loop moves from row to row, while the inner loop prints the row. Use tabs to separate the output, such as in the following statement: System.out.println(“1\t2\t3\t4\t5\t6\t7\t8\t9”); Output should look similar to the following. 1 2 3 4 5 6 7 8 9 ------------------------------------------------------------------ 1 2 3 4 5 6 7 8 9...
Prove Big O in terms of nₒ and C? There are 5 examples: class Exercise { public static int example1(int[] arr) { int n = arr.length, total = 0; for (int j=0; j < n; j++) // loop from 0 to n-1 total += arr[j]; return total; } public static int example2(int[] arr) { int n = arr.length, total = 0; for (int j=0; j < n; j += 2) // note the increment of 2 total += arr[j]; return...
Description:In this assignment, you will write a program in C++ that uses files and nested loops to create a file for real estate agents home sales and then read the sales from the file and calculates the average sale for each agent. Each agent sold 4 homes. Use a nested loop to write each agent’s sales to a file. Then read the data from the file in order to display the agent’s average sale and the average for all sales....