473,326 Members | 2,023 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Homework assignment

11
I'm using Quincy for a computer programming class and its an internet class. I'm having the hardest time doing this project:

*Create a math table which displays a series of numbers, the squares of the numbers and the
cubes of the numbers. The program should prompt the user to enter 2 values which will be the
beginning number for the table and the ending number for the table. After that a loop should be
used to display each number in the series, the square and the cube of that number as shown for
4 to 7 below. The loop should begin at the first number entered by the user and end with the last
number entered by the user.*

Can someone please help me out or atleast point me in the right direction? I have no clue how to do this!
Mar 27 '08 #1
10 1773
Sick0Fant
121 100+
I'm using Quincy for a computer programming class and its an internet class. I'm having the hardest time doing this project:

*Create a math table which displays a series of numbers, the squares of the numbers and the
cubes of the numbers. The program should prompt the user to enter 2 values which will be the
beginning number for the table and the ending number for the table. After that a loop should be
used to display each number in the series, the square and the cube of that number as shown for
4 to 7 below. The loop should begin at the first number entered by the user and end with the last
number entered by the user.*

Can someone please help me out or atleast point me in the right direction? I have no clue how to do this!
Quincy? Do you go to NIU?
Mar 27 '08 #2
PAK11
11
Quincy? Do you go to NIU?
No I don't. I go to NC State...you know anything about this?
Mar 27 '08 #3
PAK11
11
No I don't. I go to NC State...you know anything about this?
Ok sorry for not showing any work before....this is what I have so far and it will compile and build It just doesn't look right:

#include<iostream.h>
#include<cmath>

int main()
{
int num1=0;
int num2=0;


cout<<"Please enter the first number"<<endl;
cin>>num1;
cout<<"Please enter the second number"<<endl;
cin>>num2;

cout<<"Math Table"<<endl;
cout<<"Number Square Cube"<<endl;

do
{
cout<<num1<< pow(num1,2)<< pow(num1,3)<<endl;
num1=num1+1;
}while(num1<num2);


return 0;
}
Mar 27 '08 #4
Sick0Fant
121 100+
No I don't. I go to NC State...you know anything about this?
Yes. If you know how to use a for loop and you know how to square a number, the code would be about a quarter of a page.
Mar 27 '08 #5
PAK11
11
Yes. If you know how to use a for loop and you know how to square a number, the code would be about a quarter of a page.
Can you tell me what is wrong with my program so far?
Mar 27 '08 #6
Sick0Fant
121 100+
Ok sorry for not showing any work before....this is what I have so far and it will compile and build It just doesn't look right:

#include<iostream.h>
#include<cmath>

int main()
{
int num1=0;
int num2=0;


cout<<"Please enter the first number"<<endl;
cin>>num1;
cout<<"Please enter the second number"<<endl;
cin>>num2;

cout<<"Math Table"<<endl;
cout<<"Number Square Cube"<<endl;

do
{
cout<<num1<< pow(num1,2)<< pow(num1,3)<<endl;
num1=num1+1;
}while(num1<num2);


return 0;
}
You might want to put some spaces inbetween numbers... or format them, which is probably what your instructor wants
Mar 27 '08 #7
PAK11
11
You might want to put some spaces inbetween numbers... or format them, which is probably what your instructor wants
Yes my instructor wants a table format. I was going to use "\t" to space my numbers. My real problem is after I have asked for the user input, say 3 and 5, I am not sure how to include, within my loop, the process to get 3,4 and 5 all squared and cubed on the table.
Mar 27 '08 #8
Sick0Fant
121 100+
Yes my instructor wants a table format. I was going to use "\t" to space my numbers. My real problem is after I have asked for the user input, say 3 and 5, I am not sure how to include, within my loop, the process to get 3,4 and 5 all squared and cubed on the table.
Well, that's why you'll need to use iomanip. You can find how much space your largest number squared will take (since the user is supplying them at runtime.). If you just use tabs, your table will start to look askew.
Mar 27 '08 #9
PAK11
11
Well, that's why you'll need to use iomanip. You can find how much space your largest number squared will take (since the user is supplying them at runtime.). If you just use tabs, your table will start to look askew.
Sorry I don't know what you mean by tabs....Can you show me what i need to put? This is what I have and the numbers within my for statement are not spacing.

#include<iostream.h>
#include<cmath>

int main()
{
int num1=0;
int num2=0;


cout<<"Please enter the first number"<<endl;
cin>>num1;
cout<<"Please enter the second number"<<endl;
cin>>num2;

cout<<"Math Table"<<endl;
cout<<" "<<endl;
cout<<"Number\tSquare\tCube"<<endl;

for(int i=2;i<num2;i++-1)
{
cout<<num1<<pow(num1,2)<<pow(num1,3)<<endl;
num1=num1+1;
}

return 0;
}
Mar 27 '08 #10
PAK11
11
Sorry I don't know what you mean by tabs....Can you show me what i need to put? This is what I have and the numbers within my for statement are not spacing.

#include<iostream.h>
#include<cmath>

int main()
{
int num1=0;
int num2=0;


cout<<"Please enter the first number"<<endl;
cin>>num1;
cout<<"Please enter the second number"<<endl;
cin>>num2;

cout<<"Math Table"<<endl;
cout<<" "<<endl;
cout<<"Number\tSquare\tCube"<<endl;

for(int i=2;i<num2;i++-1)
{
cout<<num1<<pow(num1,2)<<pow(num1,3)<<endl;
num1=num1+1;
}

return 0;
}
Nevermind I figured it out, thanks for the help
Mar 27 '08 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: N3TB1N | last post by:
Let me try again. I could use some help with this assignment, even though my teacher does not grade assignments.but because I need to know this stuff for a test very soon, but haven't been in...
31
by: Fred Astair | last post by:
I used this site for a c++ homework assignment that my teacher left me no clue on how to do it. http://www.betterteachers.com. Check it out. Fred
11
by: spawn | last post by:
but I've been struggling with this for far too long and I'm about to start beating my head against the wall. My assignment seemed simple: create a program that will cacluate the running total of...
5
by: karafire2003 | last post by:
I was wondering if someone can help me with my homework. here's the assignment: a. Write a C program that has a declaration in main() to store the string "What's for lunch?" into an array named...
2
by: DonE | last post by:
Help me please. I am having problems with my homework assignment. We are to create a product class that hold the item number, the name of the product, the number of units in stock, and the price of...
3
by: alireza6485 | last post by:
I need to write a C# program that asks for a pattern and for each pattern beeps one and goes silence for 1 second. This is my code: for (int i=0;i< pattern; i++) { ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.