Pete,
Thank you very much for that information. It is working and saving to the file. Only one more problem that I would like to ask you about. When I open the file that it creates (book.data), it does not appear correctly for the title or the name. For instance, if I put the title as...
Actually it is not a class assignment, I am just trying to get a better understanding of the language. And I don't want to open it in a hex editor or viewer, I want to open it in notepad. And I know this is possible and I know that there is a way to do this but again I am missing...
I have changed a lot in my code. The problem I have now is that when it does write the information to disk, it does not write it correctly. It shows a lot of odd characters. What am I missing now? Seems like something simple but I am unable to locate the error.
Now I would like for the user to...
I would like to write the following information to disk. How would I go about doing so? Any tips are greatly appreciated.
#include<fstream.h>
#include<conio.h>
#include<string.h>
class Book
{
private:
char title[30];
char name[30];
double price;
int pages;
public:
void setBook(char t[]...
All I had to do was take temp.displayMeal();
out of the loop.
Everything works fine. Thank you for your help...didn't realize it was such a simple error.
It is displaying this. I input 1 calorie.
Total Weekly Calories 1
Total Weekly Calories 2
Total Weekly Calories 3
Total Weekly Calories 4
Total Weekly Calories 5
Total Weekly Calories 6
Total Weekly Calories 7
I want it to only show the last line
Total Weekly Calories 7
What do you mean call...
Okay here the code is again. I think I have made all of the necessary changes that were suggested to me. It is adding the calories but it is still displaying "Total weekly calories:" 7 times. I have tried to change everything that I can possibly think of and nothing.
Debbie...
Thank you so much, I was pulling my hair out for that one! Okay one more question if you don't mind. I want to write another main for the same program except for this time I want it to declare an array of 7 Meal objects. I let the user enter the values for the week. Then I want to total these...
How do I go about doing this? I have tried everything that I can think of and nothing. In public can I use:
void operator=(Meal &otherMeal);
And if so then what do I need to copy only the calorie and not the entree?
So it should display "Daily Total: " right? And then after that I want it to take the three meals, add the calories and display that. However even with the
Meal total("Daily Total: ", 0);
total = breakfast + lunch + dinner;
it still displays "Pizza". Is there...
I have this code and in the main function I want to display "Daily Total: " however it is displaying "Pizza" instead due to the constructor? Any suggestions on how to fix this problem?
#include<iostream.h>
#include<conio.h>
#include<string.h>
class Meal
{
friend ostream&...
Amazing what you see after you post :-) This is one part that I corrected after I posted.
istream& operator>>(istream& in, Meal &oMeal)
{
cout<<"Enter the entree name: ";
in>>oMeal.entree;
cout<<"Enter the amount of calories: ";
in>>oMeal.calorie;
return(in);
};
Thank you both! Now this is the code that I have and I think that it covers A thru D:
#include<iostream.h>
#include<conio.h>
#include<string.h>
class Meal
{
friend ostream& operator<<(ostream& out, const Meal &oMeal);
friend istream& operator>>(istream& in, Meal &oMeal);
private:
char...
Looks like a great forum! After many years going to the same job day after day I decided to take a class to see what may spark some interest. It's a free class, and we do not even get grades, just sort of an introductory. Well I am stuck (at least not on the first program) and have no idea what...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.