| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Homework Woes! Please, help...
THANKS SO MUCH FOR TAKING A LOOK AT THIS!!!! HOPE THIS IS CLEARER! -R
This is my very first introduction to C++ and I am stuck with a very simple mini-calculator project. I cannot figure out what the errors are that the compiler is showing. I have shown my written code and the compiler messages below that. I am receiving syntax errors on the 'outfile' lines where I was asked to format the output. I would appreciate any help given. Thank you, thank you!!! Code: //Description: Create a mini calculator program that will allow user to enter
//two integers [Operand 1 and Operand 2]; program will calculate sum,
//difference, whole number quotient, remainder, real number quotient, square
//root of Operand 1, and value of Operand 2 raised to the power of 4.
//**********Preprocessor Directives**********
#include <fstream>
#include <iostream>
#include <stdio.h>
#include <iomanip>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
//**********main**********
int main(void)
{
int choice, //output choice
op1, //Operand 1
op2, //Operand 2
sum, //op1 + op2
difference, //op1 – op2
product, //op1 * op2
w_quotient, //op1/op2
modulus, //op1 % op2
power; //power
long double r_quotient; //op1/op2
double y = 4, //exponent
sqrt(double op1), //finds sqrt
pow(double op1, double y); //finds power
ofstream outfile; //to write to an output file
//input sectionsystem
("cls");
cout << "Enter First Operand: ";
cin >> op1;cout << "Enter Second Operand: ";cin >> op2;
//process section
sum = op1 + op2;
difference = op1 - op2;
product = op1 * op2;
w_quotient = op1/op2;
modulus = op1 % op2;
r_quotient = op1/op2;
sqrt(op1);pow(op2, 4);
//output section
system ("cls");
cout << "Output Choice: 1 (Screen) 2 (File), (choose 1 or 2: ";
cin >> choice;if(choice==2)
outfile.open("d.minicomputer.dta");
else
outfile.open("con");
system ("cls");
outfile << setiosflags(ios::showpoint|ios::fixed)<< setprecision(2);
outfile << setw(49)"Mini Computer" << endl;
outfile << setw(49)"=============" << endl << endl;
outfile << setw(35)"Operand 1" setw(35)"Operand 2" endl;
outfile << setw(35)"=========" setw(35)"=========" endl << endl;
outfile << setw(35)op1 << setw(35)op2 << endl << endl;
outfile << setw(8)"Sum" setw(15)"Difference" setw(12)"Product" setw(19)"Whole Quotient" setw
(14)"Remainder" endl;
outfile << setw(8)"===" setw(15)"==========" setw(12)"=======" setw(19)"==============" setw
(14)"=========" endl << endl;
outfile << setw(8)sum << setw(15)difference << setw(12)product << setw(19) w_quotient << setw(14)
modulus << endl << endl;
outfile << setw(15)"Real Quotient" setw(26)"Square Root of Operand 1" setw(29)"Operand 2 to the power
of 4" endl;
outfile << setw(15)"=============" setw(26)"========================" setw
(29)"===========================" endl << endl;
outfile << setw(15)r_quotient << setw(26)sqrt << setw(29)power << endl;
outfile.close();
return 0;
}
C O M P I L E R M E S S A G E LINES 73-76 D:\minicalculator.cpp syntax error before string constant LINES 77 D:\minicalculator.cpp syntax error before `<<' token LINES 78-79 D:\minicalculator.cpp syntax error before string constant LINES 80 D:\minicalculator.cpp syntax error before `<<' token LINES 81-82 D:\minicalculator.cpp syntax error before string constant LINES 83 D:\minicalculator.cpp syntax error before `<<' token Last edited by rharvison : March 30th, 2005 at 05:41 PM. Reason: NOT CLEAR ON SCREEN |
|
#2
|
||||
|
||||
|
Any chance you could edit your post and wrap the code with [code][/code] tags?
It would make things *much* easier to read ![]() [you might need to repaste your code to preserve the indentation] |
|
#3
|
|||
|
|||
|
Code:
(cls); What is this? Why written seperately? |
|
#4
|
|||
|
|||
|
Quote:
Dear MadCowDzz, I suggest for increasing edit box's length. It is a trouble for eveyone to write properly due to space constraint.This is irrespective of coding or general comments. Please look into this. |
|
#5
|
||||
|
||||
|
Cirus:
Length and Width in my opinion... but that's all beyond my control... Most of it depends on the customization features of the Forum package we use. Your suggestion is noted though. ![]() rharvison: Thanks for modifying your post, it's easier to read now. Hopefully you'll get the guidance you are looking for. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > Homework Woes! Please, help... |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|