C++ Programming

posted by .

#include <iostream.h>
#include <stdlib.h>
#include <math.h>

int main ( )
{
double noe, nod, dc1, dc2, dc3, dc4, t;
cout << "Enter number of eggs: ";
cin >> noe;
nod = noe / 12;
dc1 = .50 / 12;
dc2 = .45 / 12;
dc3 = .40 / 12;
dc4 = .35 / 12;
cout.setf(ios::fixed);
cout.precision(3);
if (nod > 4) {
goto 1;
}
if (nod = 4 < 6) {
goto 2;
}
else
}
{
if (nod = 6 < 11)
}
goto 3;
{
else
}
{
if (nod > 11)
}
goto 4;
{
else
}
{
1:
t = noe * dc1;
cout << "Your cost is \$0.50 per dozen or " << dc1 << " per egg.";
cout << endl;
goto end;
2:
t = noe * dc2;
cout << "Your cost is \$0.45 per dozen or " << dc2 << " per egg.";
goto end;
3:
t = noe * dc3;
cout << "Your cost is \$0.40 per dozen or " << dc3 << " per egg.";
goto end;
4:
t = noe * dc4;
cout << "Your cost is \$0.35 per dozen or " << dc4 << " per egg.";
cout.setf(ios::fixed);
cout.precision(2);
cout << "Your bill comes to " << t;
cout << endl;
cout << endl;
system("Pause");
return (0);
}

If you can fix this i'll be forever greatful! i've been up for about 2 hours trying to figure it out!

Note (the goto commands weren't originally their, i thought it would work but it didn't)

• C++ Programming -

Just quickly looking...
if (nod = 4 < 6)
this will set nod true if 4 < 6.
Probably this is not what you mean.
To test for a range, you will have to separately test for the endpoints.
if( (nod >=4) && (nod <= 6) )
{
}
would test for nod greater or equal to 4 AND less than or equal to 6.

if( (nod >=4) && (nod < 6) )
{
}
would test for nod greater or equal to 4 AND less than 6.

There are a few other items, but I think the above will help you get started.

Similar Questions

1. C++

#include <iostream.h> #include <stdlib.h> int main ( ) { int choice; cout << "Computer Repair" << endl; cout << "\n Does your ailing computer beeps multiable times at startup?
2. C++

#include <iostream.h> #include <stdlib.h> int main ( ) { int choice; cout << "Computer Repair" << endl; cout << "\n Does your ailing computer beeps multiable times at startup?
3. C++ Programming

I NEED HELP WITH MY CODE!!! it won't compile right The formula for finding the force of gravity between two objects is Force = grav * (mass1 * mass2) / (radius * radius), where Force = the force of gravity between the two objects, …
4. C++ Programming

#include <iostream.h> #include <stdlib.h> #include <math.h> int main ( ) { double noe, nod, dc1, dc2, dc3, dc4, t; cout << "Enter number of eggs: "; cin >> noe; nod = noe / 12; dc1 = .50 / 12; dc2 = .45 …
5. C++ Programming

I have to redo programming exercise 5 of chapter 9 using dynamic arrays. but I have the information but I don't know how to use it in a dynamic arrays please help. //Chapter 9: Programming Exercise 5 #include <iostream> #include …
6. C++

I have no idea how to construct this program. Any help is appreciated. Thank you. In a population, the birth rate is the percentage increase of the population due to births and the death rate is the percentage decrease of the population …
7. C++ if else problem, please look

It compiles but it doesn't work. can you tell me what i did wrong?
8. programming C++

Write a program that reads test scores up to 30 into an array. sentinel will stop when -1 is entered. Write functions that: 1. read the scores into arrays 2. computes the distribution based on whether they are As, Bs and so on 3. find …
9. C++

Would you check and correct my error please! ******************************* #include<iostream.h> #include<string.h> #include<bitset> viod Binary_to_Decimal(); int main(int argv,char argc) { while(1<2) { int m_choise; …
10. c++

when i compile the following, many erors appear // include necessary libraries #include <iostream> #include <cmath> // use std namespace using namespace std; int main() { // declare the value of PI const double PI = atan( …

More Similar Questions