943,775 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 420
  • C++ RSS
Jul 3rd, 2009
0

Need help on homwork assignment.

Expand Post »
I need to create two enumerations, one for the months in the year and the other for birthstones.

Make a function named getBirthStone that returns the birthstone based on the month.
Jan-garnet
Feb-amethyst
Mar-aquamarine
Apr-diamond
May-emerald
June-pearl
July-ruby
Aug-peridot
Sep-sapphire
Oct-opal
Nov-topaz
Dec-turquoise

Add code to call the function when the user selects the display information option.

Include a menu item to the main menu to display all birth stones. Add code to call getBirthstone for each month.

I have started the assignment, but I'm not quite sure what I'm doing wrong. Any help is highly appreciated!!
C++ Syntax (Toggle Plain Text)
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. Bstone::Bstone ( string ); // consructor intializes Bstone with string supplied as argument
  8.  
  9. int main()
  10. {
  11. int name; //the user's name
  12. int Bday; //the user's birthday
  13.  
  14. //prompting the user for their name
  15. cout << "Please enter your name:\n ";
  16. cin >> name;
  17.  
  18. //prompting user for their birthday
  19. cout << "Please enter your birthday:\n ";
  20. cin >> Bday;
  21.  
  22. //prompting the user to select one of the following.
  23. cout << "Please select the following, which you want to display:\n ";
  24.  
  25. //beginning of the switch statement.
  26. switch (Useroptions)
  27. {
  28. case 1: //displaying the user's birthstone.
  29. cout << "Here is " << name << " birthstone \n";
  30. cout << "His birthday is " << Bday;
  31. break;
  32. case 2: //displaying the user's astrogical sign.
  33. cout << name << " astrogical sign is " << ....;
  34. break;
  35. case 3: //displaying the season of which the user's birthday occurs in.
  36. cout << " The season in which " << name << " birthday occurs " << "....";
  37. break;
  38. default;
  39. }
  40.  
  41. char Months, BirthStone; // Months and Birthstones of the potential users
  42.  
  43. // enumeration declaration for months
  44. enum Months { Jan = 1, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC };
  45.  
  46. // enumeration declaration for birthstones
  47. enum BirthStone { GARNET = 1, AMETHYST, AQUAMARINE, DIAMOND, EMERALD, PERAL, RUBY, PERIDOT, SAPPHIRE, OPAL, TOPAZ, TURQUOISE };
  48.  
  49. string Bstone::getBirthStone()
  50. {
  51. return Birthstone;
  52. } //end function getbirthstone
  53.  
  54.  
  55. return 0;
  56. }
Last edited by Ancient Dragon; Jul 3rd, 2009 at 11:56 pm. Reason: add code tags
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
GooeyG is offline Offline
30 posts
since Jul 2009
Jul 3rd, 2009
-1

Re: Need help on homwork assignment.

First of all, please surround your code with code tags or it makes it very hard for us to read. Second I would do this with array's, it seems it would make more sense, but this is an assignment.. Last, i would help you but you didn't do really anything just made a base and doesn't show me that you tried much.
I would love to help you but not enough effort was put into what you have so far.

You are not doing anything wrong, you just did not do anything accept for get it ready to be coded...
Last edited by u8sand; Jul 3rd, 2009 at 10:21 pm.
Reputation Points: 78
Solved Threads: 15
Junior Poster
u8sand is offline Offline
131 posts
since Dec 2008
Jul 3rd, 2009
0

Re: Need help on homwork assignment.

Quote ...
You are not doing anything wrong, you just did not do anything accept for get it ready to be coded...
@u8sand : I really think you need to look at the code first and then give your comments.I found all the mistakes listed below.And you didn't find even one ??? Which compiler do you use by the way ? The one which corrects errors on its own ???

@GooeyG:

Lots of mistakes as such :

1>Where is Bstone class defined...???

2>
c++ Syntax (Toggle Plain Text)
  1. switch(Useroptions)
Where are you asking the user for options???

3>
c++ Syntax (Toggle Plain Text)
  1. default; //Default with a semicolon ???

4>Class member function defined within main ???

5>Enumeration within main ???

6>Name and Bdate that too integer ???

And many others...So correct them first.
Last edited by csurfer; Jul 3rd, 2009 at 11:52 pm.
Reputation Points: 485
Solved Threads: 88
Posting Pro
csurfer is offline Offline
564 posts
since Jan 2009
Jul 4th, 2009
0

Re: Need help on homwork assignment.

Where are you instantiating your class ? main should just have that , move the rest of code in another file say birthstone.c/birthstone.h .
Reputation Points: 769
Solved Threads: 128
Banned
ithelp is offline Offline
1,910 posts
since May 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Tic Tac Toe
Next Thread in C++ Forum Timeline: Changing elements of lists





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC