C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old March 30th, 2005, 04:28 PM
rharvison rharvison is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 1 rharvison User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 m 9 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old March 30th, 2005, 05:03 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
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]

Reply With Quote
  #3  
Old March 31st, 2005, 02:22 AM
Cirus Cirus is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 276 Cirus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 11 h 48 m 58 sec
Reputation Power: 4
Code:
 (cls); 


What is this? Why written seperately?

Reply With Quote
  #4  
Old March 31st, 2005, 02:24 AM
Cirus Cirus is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 276 Cirus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 11 h 48 m 58 sec
Reputation Power: 4
Arrow

Quote:
Originally Posted by MadCowDzz
Any chance you could edit your post and wrap the code with tags?
It would make things *much* easier to read
[you might need to repaste your code to preserve the indentation]


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.

Reply With Quote
  #5  
Old March 31st, 2005, 09:11 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
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.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > Homework Woes! Please, help...


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT