How JustAnswer Works:

  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site.
    Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.

Ask Ingo U Your Own Question

Ingo U
Ingo U, Software Engineer
Category: Homework
Satisfied Customers: 476
Experience:  Over 25 years experience in software development. Expert in Microsoft .Net, C#, C++, VB, SQL
Type Your Homework Question Here...
Ingo U is online now
A new question is answered every 9 seconds

Write a C++ program to simulate the card game 21 for a single

Resolved Question:

Write a C++ program to simulate the card game 21 for a single player against the computer. Deal 2 cards to the computer, but only show one, and 2 cards face up to the player. Ask the player if he would like an extra card and deal one each time he answers y. If he answers n or busts (card total is greater than 21). If he busts thank the player for playing and ask if he would like to play again. If he doesn't, the computer then shows it's second card and proceeds to hit until it reaches 17 or busts. If it is a tie, both players lose. There are 52 cards in a deck, face cards should be replaced by 10's, and Aces replaced by 11's unless they would cause a bust, then they become 1's. If there is more than one ace in the hand only one at a time becomes a one. No card may be chosen twice, after an index is selected and it's value is stored, the index element should be changed to -1 before the next card is drawn. If -1 is drawn it should be ignored and another card should be drawn. If neither the player nor the computer busts, the person whose card total is closer to 21 wins. The computer should then ask if the player wants to play again and repeat the game if the player answers y and thank the player and exit if the player answers no. Please do not use bool, and keep all functions in the same file. I am using the code::blocks compiler. Comments would also be greatly appreciated as I am just learning. Also, please name a fair price. I would make an offer, but I don't know what fair is and don't want to insult you. Thank you for reading this.
Submitted: 9 months ago.
Category: Homework
Expert:  Ingo U replied 9 months ago.
Hi,
is there a deadline for this? I should be able to help.
Customer: replied 9 months ago.


Thank you, XXXXX XXXXX deadline is 11:59 PM October 7.

Expert:  Ingo U replied 9 months ago.
OK. That should be doable. As for the pay, we are not supposed to negotiate price in this category (programming). You can always decide on a bonus after you rate my service.
Customer: replied 9 months ago.


I didn't know it would tell me ahead of time how much was expected. I said October 7th, but I meant October 8th. Thank you!

Expert:  Ingo U replied 9 months ago.
Even better!
Have you used references in C++ before, e.g. to pass arguments to functions?
Customer: replied 9 months ago.

I don't understand them, but yes we have gone over them in class. We haven't covered strings yet.

Expert:  Ingo U replied 9 months ago.
Can you upload any code samples, e.g. previous homeworks, labs, etc used in class so I can gauge the level of class? Use a file sharing site like wikisend.
Thanks,
Ingo U

PS If you're not familiar with wikisend, it's easy and free:
Go to www.wikisend.com and upload the file there (no need to sign up). You will then get a page that has the File ID and Download Link. Copy either the File ID or the Download Link and come back here and paste it in your reply.

Customer: replied 9 months ago.

No, unfortunately, the professor is very low tech and doesn't give us any files to work with. We had to write a couple of programs, but the only one I can find is my latest. http://wikisend.com/download/484934/Employee pay Final.exe The class website is http://ccciss.info/ciss241/ and the last day of class is Wednesday so as far as the notes go is as much as can be used. Simpler is better. Ideally, I'd like to be able to read and understand your program as a reference for helping me write my own.

Expert:  Ingo U replied 9 months ago.
Here you go:

http://wikisend.com/download/532204/BlackJack.cpp

Please let me know if you need anything changed or explained.
Regards,
Ingo U
Expert:  Ingo U replied 9 months ago.
Hi,
were you able to use the code I provided? If not, please let me know and I'll whatever I can to correct it or help. If so, please don't forget to rate my answer, otherwise I don't get paid.
Regards,
Ingo U
Customer: replied 9 months ago.

Thank you for getting the code done so quickly. Sorry for my poor communication. I sleep during the day, have evening classes and work a full-time graveyard shift. I haven't had a chance to look this over very well yet, but I promise you I will and will rate you. The only problem with the way the program runs is that there are face cards and aces rather than being purely numerical. All of the other faults are simply that I'm a complete beginner, and can't discern an array from an argument. I may be able to figure it out, but it would be great if you could spell it out for me. Like I said, I haven't really haven't had the chance to look it over well yet, and should be asleep for another 5 hours. Also, I noticed the switch statement, but don't quite understand it's purpose, why there are cases without instructions or breaks, and it's the first time I've seen a switch without a default. My best guess to the default is that none is needed, becauses the cases are being pulled from the deck, and it isn't possible for anything other than any of those cases to be selected. Thanks in advance. -Jared

Expert:  Ingo U replied 9 months ago.
Thanks -
I interpreted the issue with the face cards to mean how many points they should count for, which is just like in the real game. It would take a little trickery dealing with the aces differently, but I could do it. I think the game is more realistic - in fact it is exactly how blackjack is played in a casino - the way it is. Perhaps you can get clarification from the instructor on this.

A switch statement is just a more readable way than writing a long chain of if-then-else statements.
The switch statement can be written like that when there is the same action to be taken for multiple cases. Think of it as saying "if the card is 2 or 3 or 4 or 5...etc then take the following action....".

And yes you're right, since the switch covers every every possible card with a corresponding case statement, a default action would never be executed.
Customer: replied 9 months ago.

I'm sorry for not being clearer when I said to replace the face cards with 10's. You're right, a casino wouldn't substitute 10's for face cards. Yes, I'm sure that he didn't want face cards, and you're right, that doesn't make any sense since face cards make it more realistic, and like suits, don't affect game play. It also doesn't make sense that he specified that in the case of a tie, both players lose, but that is an easy fix. I still haven't been to sleep yet, but now that I look at it again, it is all much clearer. Your comments are very helpful. Sorry for the inconvenience of asking you to replace the face cards with 10's. I can see how it completely changes the way the ace is treated.

Expert:  Ingo U replied 9 months ago.
THIS ANSWER IS LOCKED!
You can view this answer by clicking here to Register or Login and paying $3.
If you've already paid for this answer, simply Login.
Ingo U, Software Engineer
Category: Homework
Satisfied Customers: 476
Experience: Over 25 years experience in software development. Expert in Microsoft .Net, C#, C++, VB, SQL
Ingo U and 4 other Homework Specialists are ready to help you
Customer: replied 9 months ago.

It looks and works great! Thanks for all your help!

JustAnswer in the News:

 
 
 
Ask-a-doc Web sites: If you've got a quick question, you can try to get an answer from sites that say they have various specialists on hand to give quick answers... Justanswer.com.
JustAnswer.com...has seen a spike since October in legal questions from readers about layoffs, unemployment and severance.
Web sites like justanswer.com/legal
...leave nothing to chance.
Traffic on JustAnswer rose 14 percent...and had nearly 400,000 page views in 30 days...inquiries related to stress, high blood pressure, drinking and heart pain jumped 33 percent.
Tory Johnson, GMA Workplace Contributor, discusses work-from-home jobs, such as JustAnswer in which verified Experts answer people’s questions.
I will tell you that...the things you have to go through to be an Expert are quite rigorous.
 
 
 

What Customers are Saying:

 
 
 
  • Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help. Mary C. Freshfield, Liverpool, UK
< Last | Next >
  • Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help. Mary C. Freshfield, Liverpool, UK
  • This expert is wonderful. They truly know what they are talking about, and they actually care about you. They really helped put my nerves at ease. Thank you so much!!!! Alex Los Angeles, CA
  • Thank you for all your help. It is nice to know that this service is here for people like myself, who need answers fast and are not sure who to consult. GP Hesperia, CA
  • I couldn't be more satisfied! This is the site I will always come to when I need a second opinion. Justin Kernersville, NC
  • Just let me say that this encounter has been entirely professional and most helpful. I liked that I could ask additional questions and get answered in a very short turn around. Esther Woodstock, NY
  • Thank you so much for taking your time and knowledge to support my concerns. Not only did you answer my questions, you even took it a step further with replying with more pertinent information I needed to know. Robin Elkton, Maryland
  • He answered my question promptly and gave me accurate, detailed information. If all of your experts are half as good, you have a great thing going here. Diane Dallas, TX
 
 
 

Meet The Experts:

 
 
 
  • Manal Elkhoshkhany

    Tutor

    Satisfied Customers:

    4520
    More than 5000 online tutoring sessions.
< Last | Next >
  • http://ww2.justanswer.com/uploads/BU/BusinessTutor/2012-2-2_115741_Kouki2.64x64.jpg Manal Elkhoshkhany's Avatar

    Manal Elkhoshkhany

    Tutor

    Satisfied Customers:

    4520
    More than 5000 online tutoring sessions.
  • http://ww2.justanswer.com/uploads/LI/lindaus/2012-6-10_04811_IMG20120609164157.64x64.jpg Linda_us's Avatar

    Linda_us

    Finance, Accounts & Homework Tutor

    Satisfied Customers:

    3121
    Post Graduate Diploma in Management (MBA)
  • http://ww2.justanswer.com/uploads/ComputersGuru/2010-02-13_051118_Photo41.JPG LogicPro's Avatar

    LogicPro

    Engineer

    Satisfied Customers:

    3035
    Expert in Java C++ C C# VB Javascript Design SQL HTML
  • http://ww2.justanswer.com/uploads/lanis/2009-4-1_233717_phput9xef_c1pm.jpg Lani S.'s Avatar

    Lani S.

    Tutor

    Satisfied Customers:

    2457
    Registered Nurse, Internet Researcher, Private Tutor
  • http://ww2.justanswer.com/uploads/chooser77/2009-08-18_162025_Chris.jpg Chris M.'s Avatar

    Chris M.

    M.S.W. Social Work

    Satisfied Customers:

    2341
    Master's Degree, strong math and writing skills, experience in one-on-one tutoring (college English)
  • http://ww2.justanswer.com/uploads/JawaadAhmed/2009-6-27_12137_SIs_SHadi.jpg F. Naz's Avatar

    F. Naz

    Chartered Accountant

    Satisfied Customers:

    1975
    Experience with chartered accountancy
  • http://ww2.justanswer.com/uploads/JK/jkcpa/2011-1-16_182614_jkcpa.64x64.jpg Bizhelp's Avatar

    Bizhelp

    CPA

    Satisfied Customers:

    1873
    Bachelors Degree and CPA with Accounting work experience