您好,欢迎光临本网站![请登录][注册会员]  
文件名称: 猜数游戏 c++源代码
  所属分类: C++
  开发工具:
  文件大小: 1kb
  下载次数: 0
  上传时间: 2010-04-07
  提 供 者: elf***
 详细说明: guessing and betting number game The user starts with 100 dollars, and is able to bet and guess until they quit or have no more money. In each turn, they are asked for a bet. If they enter 0, then the program should give a farewell message and quit. The bet must be positive and within their available balance, If they enter incorrectly, the program should set the bet to their balance and tell them this. Once a bet is entered, they must pick a number between 1 and 10 (you do not need to errorcheck or correct this). This guess is t hen compared to a number the computer randomly generates each time (also between 1 and 10). If the guess is correct, the user wins the amount of their bet. If the guess is incorrect, the user will lose their bet divided by 5 and multiplied by the distance from the correct number - e.g. if the bet is 50, the computer’s number is 5 and the user guesses 7, then the user will lose 20 dollars( 50/5 * (7-5) = 20 ). However, they should not lose more than their balance, so if their balance is 50, the bet is 40, the computer’s number is 1 and the user guesses 10, (40/5 * (10-1) = 72 > 50 )then they should lose 50. After each turn, the program should display that turn's winnings (or loss amount) and the new balance,and then repeat the game until the user either quits or has no money left. Dollar values should be formatted in the standard way with two decimal places and a $ in front. Sample output from the program is below. You should make your program match this exactly (except for your name). An appropriate welcome message with your name in it should be shown at the start of the program. Assignment 1 : Guessing Game Written by yourname Please enter your bet (up to $100.00): $50 Guess a number between 1 and 10: 5 Correct! You win $50.00 Your new balance is $150.00 Please enter your bet (up to $150.00): $200 Your bet is $150.00 Guess a number between 1 and 10: 6 Wrong! The computer chose: 4 You lose $60.00 Your new balance is $90.00 Please enter your bet (up to $90.00): $80 Guess a number between 1 and 10: 1 Wrong! The computer chose: 7 You lose $90.00 Thank you for playing! Press any key to continue . . . Another Sample: CP1200 Guessing Game Written by Lindsay Ward Please enter your bet (up to $100.00): $-20 Your bet is $100.00 Guess a number between 1 and 10: 5 Wrong! The computer chose: 2 You lose $60.00 Your new balance is $40.00 Please enter your bet (up to $40.00): $10.50 Guess a number between 1 and 10: 12 Wrong! The computer chose: 2 You lose $21.00 Your new balance is $19.00 Please enter your bet (up to $19.00): $0 Thank you for playing! Press any key to continue . . . srand( static_cast(time(0))) ; 初始化 computerNumber = 1 + rand( ) % 10 ; 产生随机数 cout << fixed << setprecision(2) ; 控制输出显示2位小数 ...展开收缩
(系统自动生成,下载前可以参看下载内容)

下载文件列表

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度
  • 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.
 相关搜索: 猜数游戏 c++源代码
 输入关键字,在本站1000多万海量源码库中尽情搜索: