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

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...
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...
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 C++ program to display toy name
Write a C++ program to display toy name
Write VHDL code for the following: Use HEX-to-seven segment display converters to display the inputs and...
Write VHDL code for the following: Use HEX-to-seven segment display converters to display the inputs and results for a 4-bit adder. The inputs are unsigned 4-bit binary numbers. The outcome is a 4-bit binary adder with LED display. First you need to create a symbol for the HEX-to-seven segment display converter. Then implement a 4-bit adder using VHDL. Finally, connect three HEX-to-seven segment display converters to display input X, input Y, and sum S.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT