Advertisement
i need to make a program in which I nned to make a table with sin, cos, and tan functions from 0 - 360. I know Iam suppsoe to use M_pi...but im not getting much with that...im getting errors.
Also I have to act as if i work for the phone company and output several call durations "such as 45,43,12,17,78"
and I have to categorize them as "shorstest call, longest call, count the total number of calls made and the avergage of a call on the list"
for this one i have this:
#include<iostream.h>
#include<iomanip.h>
main()
{
int a, b, c,d,e,f;
do {
cout << "Enter first call: ";
cin >> a;
cout << "Enter second call: ";
cin >> b
..you get the idea
cout << "Enter longest calls made: ";
cin >> a;
cout << "Enter shortest calls made: ";
cin >> b
similar as before
This is so damn troublesome...im a wreck with these programs..
Also I have to act as if i work for the phone company and output several call durations "such as 45,43,12,17,78"
and I have to categorize them as "shorstest call, longest call, count the total number of calls made and the avergage of a call on the list"
for this one i have this:
#include<iostream.h>
#include<iomanip.h>
main()
{
int a, b, c,d,e,f;
do {
cout << "Enter first call: ";
cin >> a;
cout << "Enter second call: ";
cin >> b
..you get the idea
cout << "Enter longest calls made: ";
cin >> a;
cout << "Enter shortest calls made: ";
cin >> b
similar as before
This is so damn troublesome...im a wreck with these programs..
Advertisement
Advertisement
-
Re: need help
Mon, June 13, 2005 - 10:22 AMI think you need to clarify your problem(s) a little better than what is above. -
-
Re: need help
Mon, June 13, 2005 - 10:48 AMhow? two problems one i need to make a ain,cos, tan list from 0- 360 degrees..another is a list of shortest and longest calls made. -
-
Re: need help
Tue, June 14, 2005 - 1:26 PMWell, I'm not clear exactly what your instructor wants. Never took any formal classes myself so I have no frame of reference.
For one it seems you're expected to use or implement a sort algorithm. You could write a simple bubble sort, or do a compare and shuffle as values are input, or call the qsort function. It's all managing and ordering components in a list, probably easiest by manipulating an array of pointers to the elements of the list.
The other seems to be just creating a for loop for 0 thru 359 and filling the contents of a few 360 element arrays with their sin, cos vals.
It seems like the exercises would involve more, so it seems I'm missing something. -
-
Unsu...
Re: need help
Tue, June 14, 2005 - 2:43 PMSounds right Hypno. However, it looks to me like a compare and shuffle won't work since he needs to do things like averages and so on... Sounds like the instructor is trying to get them comfortable with arrays (and maybe linked lists?) and some basic algorithms and function calls.
1) a. Create arrays for each of the sin, cos, etc
b. Create a for loop from 0 to 360 and for each step calculate the sin, cos, etc, and stick it into the correct array
c. Print out the appropriate values as needed.
2) What you have already is a good basic outline if you know exactly how many calls you will have. Otherwise you have to do one of two things, either ask them for the number first, then loop through asking for more, or have them enter something like 0 or --1 to indicate they are done. You should stick these into either an array or a linked list though, since you won't know how many calls will be entered when you are writing your program.
I would use a linked list here, so you can do an insertion sort as the user enters the call lengths. Once they indicate they are done, create a loop to calculate things like averages, etc.
Good luck. Let us know if this isn't clear enough!
-
-
-
-
Re: need help
Tue, June 14, 2005 - 3:28 PMYour program isn't modern C++.
The headers are called <iostream>. There is no .h anymore, hasn't been for years.
You cannot omit the return type specifier on the definition of main, it has to be int main() ... Omitting the specifier isn't a C++ feature. It's an obsolescent feature of ANSI C for compatibility with classic C.
Lastly, the identifiers in the standard library are in a namespace. You can't use the unqualified identifiers cout and cin without a prior "using" directive.
Any of these could be causing the errors you are getting.
It sounds like you are working from some bad information about the language. You need a sound textbook that teaches modern C++ and provides correctly written examples.