hey I need some help from someone out there that is super bored. I'm trying to help a friend with his c++ hw, but I dont know anything about c++. On top of that I cant get my visual studio to work to debug this stupid thing.
1.) anyone wanna take a look at the following code and help me tweak it to at least get it to compile without errors and output something?
2.) is there a decent free program out there that works well for compiling and running c++ programs? (like using textpad for java)
#include "stdafx.h"
#include "Global.asax.h"
#include "InventoryClass.h"
#include "string.h"
namespace std
void DirectoryDisplay();
void ActOnUserInput();
void SelectOneAction();
void SelectTwoAction();
void SelectThreeAction();
void SelectFourAction();
void SaveToFile();
void DisplayAllBooks();
void DisplayBooksByAuthor();
int main()
{
ActOnUserInput();
return 0;
}
/*
* Method to display the directory options
*/
int DirectoryDisplay()
{
int selection;
cout << "Please select an option from the following:"<
1.) anyone wanna take a look at the following code and help me tweak it to at least get it to compile without errors and output something?
2.) is there a decent free program out there that works well for compiling and running c++ programs? (like using textpad for java)
#include "stdafx.h"
#include "Global.asax.h"
#include "InventoryClass.h"
#include "string.h"
namespace std
void DirectoryDisplay();
void ActOnUserInput();
void SelectOneAction();
void SelectTwoAction();
void SelectThreeAction();
void SelectFourAction();
void SaveToFile();
void DisplayAllBooks();
void DisplayBooksByAuthor();
int main()
{
ActOnUserInput();
return 0;
}
/*
* Method to display the directory options
*/
int DirectoryDisplay()
{
int selection;
cout << "Please select an option from the following:"<
[Error: Irreparable invalid markup ('<endl;>') in entry. Owner must fix manually. Raw contents below.]
hey I need some help from someone out there that is super bored. I'm trying to help a friend with his c++ hw, but I dont know anything about c++. On top of that I cant get my visual studio to work to debug this stupid thing.
1.) anyone wanna take a look at the following code and help me tweak it to at least get it to compile without errors and output something?
2.) is there a decent free program out there that works well for compiling and running c++ programs? (like using textpad for java)
<lj-cut text="code">
#include "stdafx.h"
#include "Global.asax.h"
#include "InventoryClass.h"
#include "string.h"
namespace std
void DirectoryDisplay();
void ActOnUserInput();
void SelectOneAction();
void SelectTwoAction();
void SelectThreeAction();
void SelectFourAction();
void SaveToFile();
void DisplayAllBooks();
void DisplayBooksByAuthor();
int main()
{
ActOnUserInput();
return 0;
}
/*
* Method to display the directory options
*/
int DirectoryDisplay()
{
int selection;
cout << "Please select an option from the following:"<<endl;
cout << "\t1.) Enter a book into the inventory"<<endl;
cout << "\t2.) Display all books in the inventory"<<endl;
cout << "\t3.) Search for a book by author"<<endl;
cout << "\t4.) Quit"<<endl;
cout << "Selection number: ";
cin >> selection;
while(!((selection == 1)||(selection == 2)||(selection == 3)||(selection == 4)))
{
cout << "This is not an option. Please select 1, 2, 3, or 4: ";
cin >> selection;
}//end while
return selection;
}
/*
* Method to act on specified user input
*/
void ActOnUserInput()
{
int selection = DirectoryDisplay();
if(selection == 1)
SelectionOneAction();
else if(selection == 2)
SelectionTwoAction();
else if(selection == 3)
SelectionThreeAction();
else
SelectionFourAction();
}
/*
* Method takes information entered by user when inputing a book
* into the inventory
*/
void SelectionOneAction()
{
string title;
string author;
string publisher;
string edition;
string price;
cout << "\nTitle of book to add to inventory: ";
cin >> title;
cout << "\nAuthor (last name only) of book added to inventory: ";
cin >> author;
cout << "\nPublisher of book added to inventory: ";
cin >> publisher;
cout << "\nEdition of book added to inventory: ";
cin >> edition;
cout << "\nEnter lease price (per 12 weeks): ";
cin >> price;
SaveToFile(title, author, publisher, edition, price);
ActOnUserInput();
}
/*
* Method to invoke selection number two: displaying all books
* in the inventory
*/
void SelectionTwoAction()
{
DisplayAllBooks();
ActOnUserInput();
}
/*
* Method to search for books by a specified author
*/
void SelectionThreeAction(){
string author;
cout <<"\nName of author (last name only) to search for: ";
cin >> author;
DisplayBooksByAuthor(author);
ActOnUserInput();
}
void SelectionFourAction(){
return 0;
}
void SaveToFile(string title, string author, string publisher, string edition, string price)
{
ofstream out;
out.open("test.txt", ios::app);
if(out){
out << title << end1;
out << author << end1;
out << publisher << end1;
out << edition << end1;
out << price << end1;
out.close();
}
void DisplayAllBooks()
{
ifstream in;
in.open("test.txt");
if(!in)
cout << "Error in opening file" << end1;
else
{
char ch = in.get();
while(!in.eof()){
cout << ch;
ch = in.get();
}
}
in.close();
}
void DisplayBooksByAuthor(string author)
{
}
</lj-cut>
1.) anyone wanna take a look at the following code and help me tweak it to at least get it to compile without errors and output something?
2.) is there a decent free program out there that works well for compiling and running c++ programs? (like using textpad for java)
<lj-cut text="code">
#include "stdafx.h"
#include "Global.asax.h"
#include "InventoryClass.h"
#include "string.h"
namespace std
void DirectoryDisplay();
void ActOnUserInput();
void SelectOneAction();
void SelectTwoAction();
void SelectThreeAction();
void SelectFourAction();
void SaveToFile();
void DisplayAllBooks();
void DisplayBooksByAuthor();
int main()
{
ActOnUserInput();
return 0;
}
/*
* Method to display the directory options
*/
int DirectoryDisplay()
{
int selection;
cout << "Please select an option from the following:"<<endl;
cout << "\t1.) Enter a book into the inventory"<<endl;
cout << "\t2.) Display all books in the inventory"<<endl;
cout << "\t3.) Search for a book by author"<<endl;
cout << "\t4.) Quit"<<endl;
cout << "Selection number: ";
cin >> selection;
while(!((selection == 1)||(selection == 2)||(selection == 3)||(selection == 4)))
{
cout << "This is not an option. Please select 1, 2, 3, or 4: ";
cin >> selection;
}//end while
return selection;
}
/*
* Method to act on specified user input
*/
void ActOnUserInput()
{
int selection = DirectoryDisplay();
if(selection == 1)
SelectionOneAction();
else if(selection == 2)
SelectionTwoAction();
else if(selection == 3)
SelectionThreeAction();
else
SelectionFourAction();
}
/*
* Method takes information entered by user when inputing a book
* into the inventory
*/
void SelectionOneAction()
{
string title;
string author;
string publisher;
string edition;
string price;
cout << "\nTitle of book to add to inventory: ";
cin >> title;
cout << "\nAuthor (last name only) of book added to inventory: ";
cin >> author;
cout << "\nPublisher of book added to inventory: ";
cin >> publisher;
cout << "\nEdition of book added to inventory: ";
cin >> edition;
cout << "\nEnter lease price (per 12 weeks): ";
cin >> price;
SaveToFile(title, author, publisher, edition, price);
ActOnUserInput();
}
/*
* Method to invoke selection number two: displaying all books
* in the inventory
*/
void SelectionTwoAction()
{
DisplayAllBooks();
ActOnUserInput();
}
/*
* Method to search for books by a specified author
*/
void SelectionThreeAction(){
string author;
cout <<"\nName of author (last name only) to search for: ";
cin >> author;
DisplayBooksByAuthor(author);
ActOnUserInput();
}
void SelectionFourAction(){
return 0;
}
void SaveToFile(string title, string author, string publisher, string edition, string price)
{
ofstream out;
out.open("test.txt", ios::app);
if(out){
out << title << end1;
out << author << end1;
out << publisher << end1;
out << edition << end1;
out << price << end1;
out.close();
}
void DisplayAllBooks()
{
ifstream in;
in.open("test.txt");
if(!in)
cout << "Error in opening file" << end1;
else
{
char ch = in.get();
while(!in.eof()){
cout << ch;
ch = in.get();
}
}
in.close();
}
void DisplayBooksByAuthor(string author)
{
}
</lj-cut>
