Control Statements and Jumps


Lab 04: Control Statements and Jumps-2024.10.15 
1. Write a program that requests the hours worked in a week and then prints the gross 
pay, the taxes, and the net pay. Assume the following: 
a. Basic pay rate = $10.00/hr 
b. Overtime (in excess of 40 hours) = time and a half 
c. Tax rate: #15% of the first $300, 20% of the next $150, 25% of the rest 
Use #define constants, and don’t worry if the example does not conform to current 
tax law. 
 
2. Modify assumption a. in exercise 1 so that the program presents a menu of pay rates 
from which to choose. Use a switch to select the pay rate. The beginning of a run should 
look something like this: 

Enter the number corresponding to the desired pay rate or action: 
1) $8.75/hr 2) $9.33/hr 3) $10.00/hr 4) $11.20/hr 5) quit 

The program should request the hours worked if choices 1 through 4 are selected. The 
program should recycle until 5 is entered. If something other than choices 1 through 5 
is entered, the program should remind the user what the proper options are and then 
recycle. Use #define constants for the various earning rates and tax rates. 
 
3. Write a program that accepts a positive integer as input and then displays all the 
prime numbers smaller than or equal to that number. 
 
4. The ABC Mail Order Grocery sells artichokes for $2.05 per pound, beets for $1.15 
per pound, and carrots for $1.09 per pound. It gives a 5% discount for orders of $100 
or more before adding shipping costs. It charges $6.50 shipping and handling for any 
order of 5 pounds or under, $14.00 shipping and handling for orders over 5 pounds and 
under 20 pounds, and $14.00 plus $0.50 per pound for shipments of 20 pounds or more. 
Write a program that uses a switch statement in a loop such that a response of a lets the 
user enter the pounds of artichokes desired, b the pounds of beets, c the pounds of 
carrots, and q allows the user to exit the ordering process. The program should keep 
track of cumulative totals. That is, if the user enters 4 pounds of beets and later enters 
5 pounds of beets, the program should report 9 pounds of beets. The program then 
should compute the total charges, the discount, if any, the shipping charges, and the 
total. The program then should display all the purchase information: the cost per pound, 
the pounds ordered, and the cost for that order for each vegetable, the total cost of the 
order, the discount (if there is one), the shipping charge, and the total of all the charges. 
 
Submission Requirements: Use a folder to include all source files for each question. 
For example, this lab contains three questions, so you need to create three folders, each 
of which needs to save source files for each question. Then, you need to submit the 
compressed file containing these folders to the Moodle platform. 

"sgmediation.zip" 是一个包含 UCLA(加利福尼亚大学洛杉矶分校)开发的 sgmediation 插件的压缩包。该插件专为统计分析软件 Stata 设计,用于进行中介效应分析。在社会科学、心理学、市场营销等领域,中介效应分析是一种关键的统计方法,它帮助研究人员探究变量之间的因果关系,尤其是中间变量如何影响因变量与自变量之间的关系。Stata 是一款广泛使用的统计分析软件,具备众多命令和用户编写的程序来拓展其功能,sgmediation 插件便是其中之一。它能让用户在 Stata 中轻松开展中介效应分析,无需编写复杂代码。 下载并解压 "sgmediation.zip" 后,需将解压得到的 "sgmediation" 文件移至 Stata 的 ado 目录结构中。ado(ado 目录并非“adolescent data organization”缩写,而是 Stata 的自定义命令存放目录)目录是 Stata 存放自定义命令的地方,应将文件放置于 "ado\base\s" 子目录下。这样,Stata 启动时会自动加载该目录下的所有 ado 文件,使 "sgmediation" 命令在 Stata 命令行中可用。 使用 sgmediation 插件的步骤如下:1. 安装插件:将解压后的 "sgmediation" 文件放入 Stata 的 ado 目录。如果 Stata 安装路径是 C:\Program Files\Stata\ado\base,则需将文件复制到 C:\Program Files\Stata\ado\base\s。2. 启动 Stata:打开 Stata,确保软件已更新至最新版本,以便识别新添加的 ado 文件。3. 加载插件:启动 Stata 后,在命令行输入 ado update sgmediation,以确保插件已加载并更新至最新版本。4
《Hadoop大数据技术原理与应用》课后习题答案是一本围绕Hadoop大数据技术的基础知识问答书籍,详细介绍了Hadoop的基本概念、HDFS分布式文件系统、MapReduce分布式计算框架、Zookeeper分布式协调服务等核心知识点。 一、Hadoop基本概念 Hadoop是由Apache软件基金会维护的一个开源大数据处理框架。它分为开源社区版和商业版。社区版由Apache基金会直接维护,是官方的标准版本体系。商业版Hadoop则是由第三方商业公司在社区版基础上进行修改、整合及兼容性测试后发行的版本,例如Cloudera公司的CDH版本。 二、HDFS分布式文件系统 HDFS(Hadoop Distributed File System)是Hadoop框架中的分布式文件系统,由NameNode和DataNode组成。NameNode负责管理文件系统的元数据,DataNode则负责存储文件的实际数据。HDFS具备高可扩展性、高可靠性和高性能等特点。 三、MapReduce分布式计算框架 MapReduce是一种用于处理大规模数据的分布式计算框架,其计算过程分为Map阶段和Reduce阶段。在Map阶段,MapTask将输入数据分割成小块并执行计算任务;在Reduce阶段,ReduceTask将MapTask的输出结果进行合并,最终生成结果。 四、Zookeeper分布式协调服务 Zookeeper是一种分布式协调服务,用于管理分布式应用程序的配置信息和状态信息。它提供了分布式锁、队列、监控等功能,能够帮助开发者更便捷地构建分布式应用程序。 五、Hadoop 2.0新特性 Hadoop 2.0是Hadoop的一个新版本,相比Hadoop 1.x,它在性能和可扩展性上有显著提升。Hadoop 2.0引入了ResourceManager、NodeManager和Applicat
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值