Question

What am I doing wrong here...…. Question is this : In this exercise, you will create...

What am I doing wrong here...….


Question is this :

In this exercise, you will create a program that displays a table consisting of four rows
and three columns. The first column should contain the numbers 10 through 13. The
second and third columns should contain the results of squaring and cubing, respec-
tively, the numbers 10 through 13. The table will look similar to the one shown in
Figure 9-38. If necessary, create a new project named Introductoryl6 Project, and save
it in the Cpp8\Chap09 folder. Enter your C++ instructions into a source file named
Introductoryl6.cpp. Also enter appropriate comments and any additional instructions
required by the compiler. Test the program appropriately.

Here is what I have so far, but it is not calculating it correctly nor displaying the right properties.

//Introductory16.cpp - displays table with squared and cubed calculations
//Created/revised by Kristen Arnold February 8th, 2019

#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main()
{
int dummy;

int num = 0;

cout << "Number " << "Square Root " << "Cube " << endl;
for (num = 10; num < 14; num += 1)
{
  cout << num << sqrt(num) << pow(num, 3) << endl;

} // end for

cin >> dummy;

return 0;

} //end main function

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int
main()
{
int dummy;

int num = 0;

cout << "Number "
       << "Square Root "
       << "Cube " << endl;
for (num = 10; num < 14; num += 1) {
    cout <<setw(3)<< num <<setw(10) << pow(num,2) <<setw(10)<< pow(num, 3) << endl;//squaring andnot taking the square root
    //using setw() to set the width of each field. Experiment with the numbers and see for yourself how the output changes

} // end for

cin >> dummy;

return 0;

} // end main function

Add a comment
Know the answer?
Add Answer to:
What am I doing wrong here...…. Question is this : In this exercise, you will create...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In this exercise, you will modify the hypotenuse program shown earlier in Figure 9-6. Follow the...

    In this exercise, you will modify the hypotenuse program shown earlier in Figure 9-6. Follow the instructions for starting C++ and viewing the ModifyThis13.cpp file, which is contained in either the Cpp8/Chap09/ModifyThis13 Project folder or the Cpp8/Chap09 folder. Remove both calculation tasks from the main function, and assign both to a program-defined value-returning function named getHypotenuse. Test the program appropriately. //Hypotenuse.cpp - displays the length of a right //triangle's hypotenuse #include <iostream> #include <iomanip> #include <cmath> using namespace std; int...

  • This question is about C++! Honestly, I'm not sure what I am doing right or wrong....

    This question is about C++! Honestly, I'm not sure what I am doing right or wrong. Using just functions, nothing else, I am trying to create a program that uses nothing but functions to take in two fractions, add these fractions, divide these fractions, and then display the simplified fraction all from within a menu. I would very much appreciate any leads, aid, or description on what I've done right and wrong. Thanks! #include <iostream> using namespace std; //Description: Function...

  • ////****what am i doing wrong? im trying to have this program with constructors convert inches to...

    ////****what am i doing wrong? im trying to have this program with constructors convert inches to feet too I don't know what im doing wrong. (the program is suppose to take to sets of numbers feet and inches and compare them to see if they are equal , greater, less than, or not equal using operator overload #include <stdio.h> #include <string.h> #include <iostream> #include <iomanip> #include <cmath> using namespace std; //class declaration class FeetInches { private:    int feet;   ...

  • If necessary, create a new project named Intermediate24 Project and save it in the Cpp8\Chap14 folder....

    If necessary, create a new project named Intermediate24 Project and save it in the Cpp8\Chap14 folder. Also create a new source file named Intermediate24.cpp. If you are using Microsoft Visual C++, copy the Intermediate24.txt file from the Cpp8\Chap14 folder to the Cpp8\Chap14\Intermediate24 Project folder. Use a text editor to open the Intermediate24.txt file, which contains payroll codes and salaries. Close the Intermediate24.txt file. Create a program that allows the user to enter a payroll code. The program should search for...

  • You are given a Q1.h file with overloaded function prototypes for isOrdered. Implement this overloaded function...

    You are given a Q1.h file with overloaded function prototypes for isOrdered. Implement this overloaded function into a file named Q1.cpp. Q1.cpp should only include your function implementation, the necessary #include directives if needed, and should not contain anything else such as the main function or global variable declarations. Test your code using a separate main.cpp file where you implement a sufficient number of test cases. You should use Q1.h as a header file and Q1main.cpp as a main function...

  • I am having trouble figuring out why my program will not make any columns, just rows....

    I am having trouble figuring out why my program will not make any columns, just rows. I need to display a square. The instructions are provided below. (This for my C++ class) Write a program that displays a square. Ask the user for the square’s size. Only accept positive integer numbers (meaning choose a data type that holds positive integer values). The size the user gives you will determine the length and width of the square. The program should then...

  • C++: Need help debugging my code I am writing this and using some other examples as reference code while rewriting it with my own understanding of the material but am having trouble making it finally...

    C++: Need help debugging my code I am writing this and using some other examples as reference code while rewriting it with my own understanding of the material but am having trouble making it finally compile. Below is a picture of the error messages. //main.cpp //Semester Project //Created by J---on 5/6/2019 #include <iostream> #include <fstream> #include <string> #include <sstream> #include <bits/stdc++.h> using namespace std; void instructions(); //displays program details and instructions void openFile(); void takeInput(int*); void switchBoard(int*); struct price {...

  • Creating a Class in C++ Summary In this lab, you create a programmer-defined class and then...

    Creating a Class in C++ Summary In this lab, you create a programmer-defined class and then use it in a C++ program. The program should create two Rectangle objects and find their area and perimeter. Instructions Ensure the class file named Rectangle.cpp is open in your editor. In the Rectangle class, create two private attributes named length and width. Bothlength and width should be data type double. Write public set methods to set the values for lengthand width. Write public...

  • Hi there, I am working on a binary search tree code in c++. The program must...

    Hi there, I am working on a binary search tree code in c++. The program must store and update students' academic records, each node includes the student name, credits attempted, credits earned and GPA. I have made some progress with the code and written most of the functions in the .cpp file (already did the .h file) but i am struggling with what to put in the main and how to put an update part in the insert function. I...

  • Theres an error on The bolded line, what am I doing wrong? #include <iostream> //just for...

    Theres an error on The bolded line, what am I doing wrong? #include <iostream> //just for writing and reading from console #include <fstream> //this one to deal with files, read and write to text files using namespace std; int main() { //first thing we need to read the data in the text file //let's assume we have the reading in a text file called data.txt //so, we need a stream input variable to hold this data ifstream infile; //now we...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT