Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 10-24-2005, 06:21 PM   #1 (permalink)
Voli
Registered User
 
Join Date: Oct 2005
Posts: 2
Voli is on a distinguished road
New to C++ and so lost :S


Last edited by Voli; 10-25-2005 at 01:06 PM.
Voli is offline   Reply With Quote
Old 10-25-2005, 02:46 AM   #2 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,705
redhead is on a distinguished road
Code:
115:  out << setw(10) << "Day" 
         << set(10) << t.day << "|" << setw(10) << "Low" 
         << set(10) << t.low << "|" << setw(10) << "High" 
         << set(10) << t.high << "|" << setw(10) << "Normal" 
         << set(10) << endl;
Do you see the error now ??

2. Open the file for input. test for failure, and repeat until a valid filename is entered.
It's not doing that, returning with exit(1); isn't telling it to ask the user again.
Code:
while(fin.fail())
{
  cout << "Enter the name of the data file: ";
  cin >> filename;
  fin.open(filename);
  if(fin.fail())
     cout << "Error opening file: " << filename << endl;
}
would be one way to achieve that.

  • A line that displays the year and month of the data contained in the report.
  • A header line that labels each of the columns.
  • A record for each day of data read in. Each record should contain:
    • Day (as a number)
    • Low (F)
    • High (F)
    • Average (F) (which is defined as (Low + High) / 2.0).
    • Difference from normal (F) This is defined as the actual average temp minus the normal temp for the day. Use the actual number
  • the bottom outputs the average temperature for the month in both Fahrenheit and Celsius.
This is not happening, you call generate_report() but itjust copies the input file directly to the output file.

Read your code closely while keeping those restrictions in mind.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 10-25-2005, 03:13 AM   #3 (permalink)
Voli
Registered User
 
Join Date: Oct 2005
Posts: 2
Voli is on a distinguished road
Thanks for replying , yeah i do see what i did wrong

i've updated the code and now i get a parse error but i don't see where it is wrong

In function `void generate_report(ifstream &, ostream &)':
92: parse error before `t'

Last edited by Voli; 10-25-2005 at 01:07 PM.
Voli is offline   Reply With Quote
Old 10-25-2005, 08:48 AM   #4 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,705
redhead is on a distinguished road
Code:
...
double avg = 0;
while (read_record(fin,t))
{
  write_record(out,t);
  count ++ 
  avg t = (t.low + t.high)/2.0
  // output average
  cout << avg t << endl;
...
You might wanna address your variable with avg since that's what you're calling it..
So it would be:
Code:
...
double avg = 0;
while (read_record(fin,t))
{
  write_record(out,t);
  count ++ ;
  avg = (t.low + t.high)/2.0 ;
  // output average
  cout << avg << endl;
...
Next time proof read your code more, the 92 infront of the error indicates what line is is pressented on..
The easiest way is to scroll to where the first error tells you it is, see if anything there is missing/wrong, correct that and see if that eliminates the error.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 10-26-2005, 12:55 AM   #5 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,705
redhead is on a distinguished road
Don't just edit your previus post, today I was in the mood to make my own implementation of your temperature program, now I have no code or description from your part to start from.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 10-26-2005, 01:05 AM   #6 (permalink)
teknomage1
Jack of all trades
 
teknomage1's Avatar
 
Join Date: Feb 2005
Location: Los Angeles
Posts: 598
teknomage1 is on a distinguished road
Send a message via AIM to teknomage1
I don't get this mindset of, "My question is answered, time to delete my post." Where does this idea come from? If people aren't interested in leaving a record, why don't they use irc? Argh.
__________________
Stop intellectual property from infringing on me
teknomage1 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -8. The time now is 09:06 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting