473,386 Members | 1,830 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Help with a survey program

Yea im trying to make a christmas survey program for my class project, Im using strings to set 20 variables, Not a experienced programmer this is my first year in classes just trying to learn and need a bit of help. my program wont even do anything it says no errors, runs then says press any key to continue.. Any help someone can offer would be greatly appreciated
Expand|Select|Wrap|Line Numbers
  1. // survey.cpp - This is a survey of 30 basic questions, The program will ask, user will answer, program will save answers then print.
  2. // Created/Revised by <Jeff Shaffer> on <11-27-06>.
  3.  
  4. #include "stdafx.h"
  5. #include <iostream>
  6.  
  7. using std::cout;
  8. using std::cin;
  9. using std::endl;
  10.  
  11. int main()
  12. {
  13.     //declare variables
  14.     string name = "";
  15.     string ans1 = "";
  16.     string ans2 = "";
  17.     string ans3 = "";
  18.     string ans4 = "";
  19.     string ans5 = "";
  20.     string ans6 = "";
  21.     string ans7 = "";
  22.     string ans8 = "";
  23.     string ans9 = "";
  24.     string ans10 = "";
  25.     string ans11 = "";
  26.     string ans12 = "";
  27.     string ans13 = "";
  28.     string ans15 = "";
  29.     string ans15 = "";
  30.     string ans16 = "";
  31.     string ans17 = "";
  32.     string ans18 = "";
  33.     string ans19 = "";
  34.     string ans20 = "";
  35.     int ready = "";
  36.  
  37.     //Enter input data
  38.     cout << "Enter your full name: ";
  39.     getline(cin, name);
  40.     cout << "This survey consists of 20 basic questions";
  41.     cout << "Ready to begin? Yes/No";
  42.     cin >> ready;
  43.  
  44.     //darw
  45.     cout << "Hot chocolate or apple cider: ";
  46.     cin >> ans1;
  47.     cout << "Turkey or Ham: ";
  48.     cin >> ans2;
  49.     cout << "Do you get a fake or 'real cut' Xmas tree: ";
  50.     cin >> ans3;
  51.     cout << "Decorations on the outside of your house: ";
  52.     cin >> ans4;
  53.     cout << "Snowball fights or sledding: ";
  54.     cin >> ans5;
  55.     cout << "Do you like hanging around the fireplace because its warm: ";
  56.     cin >> ans6;
  57.     cout << "Do you enjoy xmas shopping: ";
  58.     cin >> ans7;
  59.     cout << "Favorite christmas song: ";
  60.     cin >> ans8;
  61.     cout << "Take a break, you at 9/20 ";
  62.     cout << "how do you feel about christmas movies: ";
  63.     cin >> ans10;
  64.     cout << "when is it to early to start listening to christmas music: ";
  65.     cin >> ans11;
  66.     cout << "Stockings before or after presents: ";
  67.     cin >> ans12;
  68.     cout << "do you like christmas carolers: ";
  69.     cin >> ans13;
  70.     cout << "go to someone elses house or they come to yours: ";
  71.     cin >> ans14;
  72.     cout << "do you read the christmas story the night before christmas: ";
  73.     cin >> ans15;
  74.     cout << "Question16: ";
  75.     cin >> ans16;
  76.     cout << "Question17: ";
  77.     cin >> ans17;
  78.     cout << "Question18: ";
  79.     cin >> ans18;
  80.     cout << "Question19: ";
  81.     cin >> ans19;
  82.     cout << "Question20: ";
  83.     cin >> ans20;
  84.     cout << "Thanks for taking our survey, Your all finished";
  85.  
  86.  
  87.       return 0;
  88.     } // end of main function
Nov 30 '06 #1
5 3805
Ganon11
3,652 Expert 2GB
Yea im trying to make a christmas survey program for my class project, Im using strings to set 20 variables, Not a experienced programmer this is my first year in classes just trying to learn and need a bit of help. my program wont even do anything it says no errors, runs then says press any key to continue.. Any help someone can offer would be greatly appreciated
Expand|Select|Wrap|Line Numbers
  1. // survey.cpp - This is a survey of 30 basic questions, The program will ask, user will answer, program will save answers then print.
  2. // Created/Revised by <Jeff Shaffer> on <11-27-06>.
  3.  
  4. #include "stdafx.h"
  5. #include <iostream>
  6.  
  7. using std::cout;
  8. using std::cin;
  9. using std::endl;
  10.  
  11. int main()
  12. {
  13.     //declare variables
  14.     string name = "";
  15.     string ans1 = "";
  16.     string ans2 = "";
  17.     string ans3 = "";
  18.     string ans4 = "";
  19.     string ans5 = "";
  20.     string ans6 = "";
  21.     string ans7 = "";
  22.     string ans8 = "";
  23.     string ans9 = "";
  24.     string ans10 = "";
  25.     string ans11 = "";
  26.     string ans12 = "";
  27.     string ans13 = "";
  28.     string ans15 = "";
  29.     string ans15 = "";
  30.     string ans16 = "";
  31.     string ans17 = "";
  32.     string ans18 = "";
  33.     string ans19 = "";
  34.     string ans20 = "";
  35.     int ready = "";
  36.  
  37.     //Enter input data
  38.     cout << "Enter your full name: ";
  39.     getline(cin, name);
  40.     cout << "This survey consists of 20 basic questions";
  41.     cout << "Ready to begin? Yes/No";
  42.     cin >> ready;
  43.  
  44.     //darw
  45.     cout << "Hot chocolate or apple cider: ";
  46.     cin >> ans1;
  47.     cout << "Turkey or Ham: ";
  48.     cin >> ans2;
  49.     cout << "Do you get a fake or 'real cut' Xmas tree: ";
  50.     cin >> ans3;
  51.     cout << "Decorations on the outside of your house: ";
  52.     cin >> ans4;
  53.     cout << "Snowball fights or sledding: ";
  54.     cin >> ans5;
  55.     cout << "Do you like hanging around the fireplace because its warm: ";
  56.     cin >> ans6;
  57.     cout << "Do you enjoy xmas shopping: ";
  58.     cin >> ans7;
  59.     cout << "Favorite christmas song: ";
  60.     cin >> ans8;
  61.     cout << "Take a break, you at 9/20 ";
  62.     cout << "how do you feel about christmas movies: ";
  63.     cin >> ans10;
  64.     cout << "when is it to early to start listening to christmas music: ";
  65.     cin >> ans11;
  66.     cout << "Stockings before or after presents: ";
  67.     cin >> ans12;
  68.     cout << "do you like christmas carolers: ";
  69.     cin >> ans13;
  70.     cout << "go to someone elses house or they come to yours: ";
  71.     cin >> ans14;
  72.     cout << "do you read the christmas story the night before christmas: ";
  73.     cin >> ans15;
  74.     cout << "Question16: ";
  75.     cin >> ans16;
  76.     cout << "Question17: ";
  77.     cin >> ans17;
  78.     cout << "Question18: ";
  79.     cin >> ans18;
  80.     cout << "Question19: ";
  81.     cin >> ans19;
  82.     cout << "Question20: ";
  83.     cin >> ans20;
  84.     cout << "Thanks for taking our survey, Your all finished";
  85.  
  86.  
  87.       return 0;
  88.     } // end of main function
Well, I can notice one thing: You have declared the variable ready as an integer - shouldn't it be a string?

Also, since you are asking if the user is ready, shouldn't you account for the possibility that they say "No"?
Nov 30 '06 #2
Well the program isnt finished, Im not sure how to make the program acctually if the user enters Yes - run and if they enter No - restart.. i know ill have to use a while statement to make it a loop but yea.. and for the ready variable it may need to be a string idont know. But i planned to fix the ready command; I would just like to be able to see the program work somewhat first though
Nov 30 '06 #3
r035198x
13,262 8TB
Well the program isnt finished, Im not sure how to make the program acctually if the user enters Yes - run and if they enter No - restart.. i know ill have to use a while statement to make it a loop but yea.. and for the ready variable it may need to be a string idont know. But i planned to fix the ready command; I would just like to be able to see the program work somewhat first though
Let's get one point clarified. You said the program compiles but when you run it does nothing?
Nov 30 '06 #4
Allright I played around with everything fixed my small errors; and I got it running but the problem im experiencing now well heres the code
Expand|Select|Wrap|Line Numbers
  1. // survey.cpp - This is a survey of 20 Christmas questions, The program will ask, user will answer, program will save answers then print.
  2. // Created/Revised by <Jeff Shaffer> on <11-27-06>.
  3.  
  4. #include "stdafx.h"
  5. #include <iostream>
  6. #include <string>
  7.  
  8. using std::cout;
  9. using std::cin;
  10. using std::endl;
  11. using std::string;
  12.  
  13. int main()
  14. {
  15.     //Declare string variables
  16.     string name = "";
  17.     string ans1 = "";
  18.     string ans2 = "";
  19.     string ans3 = "";
  20.     string ans4 = "";
  21.     string ans5 = "";
  22.     string ans6 = "";
  23.     string ans7 = "";
  24.     string ans8 = "";
  25.     string ans9 = "";
  26.     string ans10 = "";
  27.     string ans11 = "";
  28.     string ans12 = "";
  29.     string ans13 = "";
  30.     string ans14 = "";
  31.     string ans15 = "";
  32.     string ans16 = "";
  33.     string ans17 = "";
  34.     string ans18 = "";
  35.     string ans19 = "";
  36.     string ans20 = "";
  37.  
  38.  
  39.     //Enter input data
  40.     cout << "Enter your full name: ";
  41.     getline(cin, name);
  42.     cout << "This survey consists of 20 basic questions"<<endl;
  43.  
  44.  
  45.     //Program asks the user the question, user types in answer and program saves the answer
  46.     cout << "Hot chocolate or apple cider: ";
  47.     getline(cin, ans1);
  48.     cout << "Turkey or Ham: ";
  49.     getline(cin, ans2);
  50.     cout << "Do you get a fake or 'real cut' Xmas tree: ";
  51.     getline(cin, ans3);
  52.     cout << "Decorations on the outside of your house: ";
  53.     getline(cin, ans4);
  54.     cout << "Snowball fights or sledding: ";
  55.     getline(cin, ans5);
  56.     cout << "Do you like hanging around the fireplace because its warm: ";
  57.     getline(cin, ans6);
  58.     cout << "Do you enjoy xmas shopping: ";
  59.     getline(cin, ans7);
  60.     cout << "Favorite christmas song: ";
  61.     getline(cin, ans8);
  62.     cout << "Take a break, you at 9/20 "<<endl;
  63.     cout << "how do you feel about christmas movies: ";
  64.     getline(cin, ans9);
  65.     cout << "when is it to early to start listening to christmas music: ";
  66.     getline(cin, ans10);
  67.     cout << "Stockings before or after presents: ";
  68.     getline(cin, ans11);
  69.     cout << "do you like christmas carolers: ";
  70.     getline(cin, ans12);
  71.     cout << "go to someone elses house or they come to yours: ";
  72.     getline(cin, ans13);
  73.     cout << "do you read the christmas story the night before christmas: ";
  74.     getline(cin, ans14);
  75.     cout << "Do you enjoy christmas?: ";
  76.     getline(cin, ans15);
  77.     cout << "Did you get someone a gift: ";
  78.     getline(cin, ans16);
  79.     cout << ": Do you think you'll get any presents: ";
  80.     getline(cin, ans17);
  81.     cout << "what do you eat for christmas dinner: ";
  82.     getline(cin, ans18);
  83.     cout << "Do you beleive in Santa Clause: ";
  84.     getline(cin, ans19);
  85.     cout << "Thanks for taking our survey, Your all finished" << endl;
  86.  
  87.     //Displaying the answers for the survey instructor to copy down
  88.     cout << "Please do not close the program, The instructor will now begin to copy down your answers" >> endl;
  89.     cout << "Answer #1:" << ans1 << endl;
  90.     cout << "Answer #2:" << ans2 << endl;
  91.     cout << "Answer #3:" << ans3 << endl;
  92.     cout << "Answer #4:" << ans4 << endl; 
  93.     cout << "Answer #5:" << ans5 << endl; 
  94.     cout << "Answer #6:" << ans6 << endl; 
  95.     cout << "Answer #7:" << ans7 << endl;
  96.     cout << "Answer #8:" << ans1 << endl; 
  97.     cout << "Answer #9:" << ans8 << endl; 
  98.     cout << "Answer #10:" << ans10 << endl; 
  99.     cout << "Answer #11:" << ans11 << endl; 
  100.     cout << "Answer #12:" << ans12 << endl; 
  101.     cout << "Answer #13:" << ans13 << endl; 
  102.     cout << "Answer #14:" << ans14 << endl; 
  103.     cout << "Answer #15:" << ans15 << endl; 
  104.     cout << "Answer #16:" << ans16 << endl; 
  105.     cout << "Answer #17:" << ans17 << endl; 
  106.     cout << "Answer #18:" << ans18 << endl; 
  107.     cout << "Answer #19:" << ans19 << endl; 
  108.     cout << "Answer #20:" << ans20 << endl; 
  109.  
  110. }   // end of main function
I get like 45 error when i compile that, Their random errors that talk about stuff that does involve my code at all, IT worked fine until I added
Expand|Select|Wrap|Line Numbers
  1. //Displaying the answers for the survey instructor to copy down
  2.     cout << "Please do not close the program, The instructor will now begin to copy down your answers" >> endl;
  3.     cout << "Answer #1:" << ans1 << endl;
  4.     cout << "Answer #2:" << ans2 << endl;
  5.     cout << "Answer #3:" << ans3 << endl;
  6.     cout << "Answer #4:" << ans4 << endl; 
  7.     cout << "Answer #5:" << ans5 << endl; 
  8.     cout << "Answer #6:" << ans6 << endl; 
  9.     cout << "Answer #7:" << ans7 << endl;
  10.     cout << "Answer #8:" << ans1 << endl; 
  11.     cout << "Answer #9:" << ans8 << endl; 
  12.     cout << "Answer #10:" << ans10 << endl; 
  13.     cout << "Answer #11:" << ans11 << endl; 
  14.     cout << "Answer #12:" << ans12 << endl; 
  15.     cout << "Answer #13:" << ans13 << endl; 
  16.     cout << "Answer #14:" << ans14 << endl; 
  17.     cout << "Answer #15:" << ans15 << endl; 
  18.     cout << "Answer #16:" << ans16 << endl; 
  19.     cout << "Answer #17:" << ans17 << endl; 
  20.     cout << "Answer #18:" << ans18 << endl; 
  21.     cout << "Answer #19:" << ans19 << endl; 
  22.     cout << "Answer #20:" << ans20 << endl; 
  23.  
Someone shine some light on me? ALSO my original plans were to PRINT the answers but i wasnt sure the print syntax.. if anyone could maybe tell me that then I would rather print then just say the answers back. Thank you
Dec 1 '06 #5
Ganon11
3,652 Expert 2GB
Expand|Select|Wrap|Line Numbers
  1. //Displaying the answers for the survey instructor to copy down
  2.     cout << "Please do not close the program, The instructor will now begin to copy down your answers" >> endl; // BRACKETS FACING WRONG WAY!
  3.     cout << "Answer #1:" << ans1 << endl; // Brakcets should be '<<', not '>>'
  4.     cout << "Answer #2:" << ans2 << endl;
  5.     cout << "Answer #3:" << ans3 << endl;
  6.     cout << "Answer #4:" << ans4 << endl; 
  7.     cout << "Answer #5:" << ans5 << endl; 
  8.     cout << "Answer #6:" << ans6 << endl; 
  9.     cout << "Answer #7:" << ans7 << endl;
  10.     cout << "Answer #8:" << ans1 << endl; 
  11.     cout << "Answer #9:" << ans8 << endl; 
  12.     cout << "Answer #10:" << ans10 << endl; 
  13.     cout << "Answer #11:" << ans11 << endl; 
  14.     cout << "Answer #12:" << ans12 << endl; 
  15.     cout << "Answer #13:" << ans13 << endl; 
  16.     cout << "Answer #14:" << ans14 << endl; 
  17.     cout << "Answer #15:" << ans15 << endl; 
  18.     cout << "Answer #16:" << ans16 << endl; 
  19.     cout << "Answer #17:" << ans17 << endl; 
  20.     cout << "Answer #18:" << ans18 << endl; 
  21.     cout << "Answer #19:" << ans19 << endl; 
  22.     cout << "Answer #20:" << ans20 << endl; 
  23.  
Someone shine some light on me?
The error is in your first line of code - instead of saying

cout << "Whatever." << endl;

you had

cout << "Whatever." >> endl;

which doesn't work, because >> doesn't exist for cout.
Dec 1 '06 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: GTF | last post by:
PHP Web Survey Idea.. I have been given an opportunity to create a web based survey. This is a fairly lengthy survey of 60 pages on paper (various multiple choice and free form). These are...
5
by: Dan | last post by:
Hi, I want to migrate a survey program to web application and have selected PHP to use a on the server end along with apache and firebird rdms. As developing a web application is much different...
7
by: elena | last post by:
Apologies for this off-topic post. I'm a Java/C++ developer who is also studying psychology. I would really appreciate it if you would complete a survey that I'm using for a research project...
0
by: urbann_animals | last post by:
The Masters of Science in Technical Communication Program at the University of Colorado - Denver is doing a study to determine the feasability of offering some or most of its curriculum via online...
0
by: Henry | last post by:
Hi Everyone, My name is Henry and I'm a Master of Computing student at Unitec New Zealand (www.unitec.ac.nz). I'm currently doing my Thesis titled: "Utilizing Newsgroups as Customer Support Tool...
7
by: Papelotte | last post by:
Hi all, I'm new to this forum and I am hoping that there is someone here who can help me. I have an ASP page that has javascript that works perfectly in IE, but not in Firefox. Can anybody tell...
1
by: jerger | last post by:
I have not made a program or page from start yet. I have made modifications to our signoff asp pages like changing the questions, texts, shortening field lengths etc... I also have copied the files...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.