Question

In: Computer Science

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

Solutions

Expert Solution

//Comment me if you want any changes below is the link to the code

// link : https://repl.it/@FAYAZPASHA/EmbellishedCarelessDeals#main.cpp

#include<bits/stdc++.h>

using namespace std;

int main(){

   cout << "x\tx^2\tx^3\n";
   int x = 11; // declaring my variables
   int a = 0; // a, b, c just to maintain the sum
   int b = 0;
   int c = 0;
   for(; x < 39; x += 3){
       a += x; // summing the values
       b += (x * x);
       c += (x * x * x);
       cout << x << "\t" << x * x << "\t" << x * x * x << endl;
   }
   cout << "Totals : ";
   cout << a << "\t" << b << "\t" << c << endl; // printing the totals
   return 0;
}


Related Solutions

IN C++: Write a program to display the following table. MUST use for-loop Enter the table...
IN C++: Write a program to display the following table. MUST use for-loop Enter the table size: 10 N N^2 Square root of N --------------------------------------------- 1 1 1.00 2 4 1.41 3 9 1.73 ….. 10 100 3.16
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...
[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 +...
I want the program to use 1- D array and display a table as output. Write...
I want the program to use 1- D array and display a table as output. Write a script to simulate the rolling of two dice. The script should use Math.random to roll the first die and again to roll the second die. The sum of the two values should then be calculated. [Note: Since each die can show an integer value from 1 to 6, the sum of the values will vary from 2 to 12, with 7 being the...
Meant to be written in Java JDK 14.0 Write a program to display the conversion table...
Meant to be written in Java JDK 14.0 Write a program to display the conversion table from meter to feet using formatted output (printf()): 1 meter = 3.28084 feet; 1 foot = 12 inch When display the number, round the number to 2 decimal places. Set the number in the 1st the 2nd columns to the left align, set the 3rd column to the right align: meter(s) feet inch(es) 1 3.28 37.37 2 x.xx xx.xx 3 x.xx xxx.xx
Write a program to calculate the area and circumference of a cuboid. Use printf to display...
Write a program to calculate the area and circumference of a cuboid. Use printf to display 2 digits after decimal point in all the results Program should be in java language.
Write a program to use Math methods to calculate and display the followings: Prompts the user...
Write a program to use Math methods to calculate and display the followings: Prompts the user to enter an angle, in degrees, and then display the angle in radians and the Sine of the angle. Prompts the user to enter a positive integer and calculates the square root of the number. Computational thinking: Your program must check if it is a positive number. If a negative number is entered, it must ask for another number until the positive number is...
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 simple airline ticket reservation program. The program should display a menu with the following...
Write a simple airline ticket reservation program. The program should display a menu with the following options: reserve a ticket, cancel a reservation, check whether a ticket is reserved for a particular person, and display the passengers. The information is maintained on an alphabetized linked list of names. In a simpler version of the program, assume that tickets are reserved for only one flight. In a fuller version, place no limit on the number of flights. Create a linked list...
Write a java program that will first display the following menu: Choose one of the following...
Write a java program that will first display the following menu: Choose one of the following 1- To add 2 double integers 2- To add 2 integer numbers 3- To add 3 double numbers 4- To add 3 integer numbers After reading user’s choice, use a switch case statement to call the corresponding method Void add 1 (double n1, double n2) Void add2() Double add3 (double n1, double n2, double n3) Double add4 ()
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT