Computer Science, Claremont McKenna College
CS51.2 - Introduction to Computer Science, Fall 2014
Problem Set 2 Due: 11:55 AM, Sept 18, 2014
General Instructions
Please carefully read and follow the directions exactly for each problem. Files and classes should be
named exactly as directed in the problem (including capitalization!) as this will help with grading.
You should create your programs using your preferred text-editor, the Eclipse text editor, or jGrasp. Do
not use a word processor such as Microsoft Word, WordPad, Google Docs, Apple’s Pages, etc...
Your programs should be formatted in a way that’s readable. In other words, indent appropriately, use
informative names for variables, etc… If you are uncertain about what is a readable style, look at the
examples from class as a starting point for a reasonable coding style.
This problem set assumes you have installed Java and an IDE (Eclipse or jGrasp) on your system. Please
see the course web page on Sakai for installation instructions.
Your programs should compile and run without errors. Please do not submit programs that do not
compile! It’s better to submit partial implementation that compiles as oppose to implementations that do
not compile.
At the top of each file you submit, you should put your name and your email as comments.
This homework set should be submitted via Sakai using the Assignment Menu option (on the left pane).
You should only submit the requested “.java” files. Do not submit “.class” files or Eclipse-specific
project files. Finally, please do not submit files using Sakai’s Dropbox Menu.
Turn in the following file(s):
MilesToFeet.java
DollarsToBills.java
DollarFigure.java
FactorialLoop.java
Problem 1
In this warmup problem, write a program in MilesToFeet.java that converts a specified number of
miles into number of feet. Declare a variable named numMiles that’s initialized to 11.3. Declare
another variable named numFeet. Think about what type these variables should be. You should then
perform the conversion from miles to feet and assign the value to numFeet. Print something informative
such as “X miles is Y feet.”
Problem 2
Write a program in DollarsToBills.java that converts a specified number of dollars into the
number of twenty dollar bills, the number of ten dollar bills, the number of five dollar bills, and the
number of one dollar bills. In doing this conversion, you should first maximize the number of twenty
dollar bills, then maximize the number of ten dollar bills, etc… Declare a variable named nDollars
and assign 99 to it. Declare a variable named nTwenty to hold the number of twenty dollar bills,
nTens to hold the number of ten dollar bills, nFives to hold the number of five dollar bills and nOnes
to hold the number of one dollar bills. Think about what type these variables should be. (You may use
other variables as needed.) Print out the conversion with meaningful annotation such “99 dollars is equal
to 4 twenties, 1 tens, …”
Problem 3
In a file named DollarFigure.java , write a program that uses for loops to produce the following:
$$$$$$$**************$$$$$$$
**$$$$$$************$$$$$$**
****$$$$$**********$$$$$****
******$$$$********$$$$******
********$$$******$$$********
**********$$****$$**********
************$**$************
Problem 4
Using nested for loops, write a program in FactorialLoop.java that calculates and then prints out
the factorial of the numbers from 3 to 9 (inclusive). Print out the factorials in the following form:
3 factorial is equal to 6
4 factorial is equal to 24
etc…
Consider using a variable to track the intermediate “running” factorial result as the factorial is being
calculated in a loop.

java代写的更多相关文章

  1. 程序代写, CS代写, 代码代写, CS编程代写, java代写, python代写, c++/c代写, R代写, 算法代写, web代写

    互联网一线工程师程序代写 微信联系 当天完成 查看大牛简介特色: 学霸代写,按时交付,保证原创,7*24在线服务,可加急.用心代写/辅导/帮助客户CS作业. 客户反馈与评价 服务质量:保证honor ...

  2. CS代码代写, 程序代写, java代写, python代写, c/c++代写,csdaixie,daixie,作业代写,代写

    互联网一线工程师程序代写 微信联系 当天完成特色: 互联网一线工程师 24-48小时完成.用心代写/辅导/帮助客户CS作业. 客户反馈与评价 服务质量:保证honor code,代码原创.参考课程sl ...

  3. C++代做,C++编程代做,C++程序代做,留学生C++ Lab代写

    C++代做,C++编程代做,C++程序代做 我们主要面向留学生,广泛接美加澳国内港台等地编程作业代写,中英文均可. C语言代写 C++代写 Python代写 Golang代写 Java代写 一年半的时 ...

  4. Java作业代写

    作业一 试用java编写一个九九乘法表并打印. 作业二: 设计两个人类与书类,并设置两者的关系,试用人去找书,书去找人,假如某人有一个儿子,它也有一本书,试用儿子去找书,书找儿子. 大作业 熟悉QQ农 ...

  5. 基于JAVA WEB技术旅游服务网站系统设计与实现网上程序代写

    基于JAVA WEB技术旅游服务网站系统设计与实现网上程序代写 专业程序代写服务(QQ:928900200) 随着社会的进步.服务行业的服务水平不断发展与提高,宾馆.酒店.旅游等服务行业的信息量和工作 ...

  6. 模拟游客一天的生活与旅游java程序代写源码

    在某个城市的商业区里,有一家首饰店,一家饭店,一家面馆,一家火锅店,一家银行,一家当铺 现在有一群来自四川的游客,一群陕西的游客,一群上海的游客,和以上各店家的工作人员在此区域里,请模拟他们一天的生活 ...

  7. 代写assignment

    集英服务社,强于形,慧于心 集英服务社,是一家致力于优质学业设计的服务机构,为大家提供优质原创的学业解决方案.多年来,为海内外学子提供了多份原创优质的学业设计解决方案. 集英服务社,代写essay/a ...

  8. java 学习写架构必会几大技术点

    java 学习写架构必会几大技术点 关于学习架构,必须会的几点技术 1. java反射技术 2. xml文件处理 3. properties属性文件处理 4. 线程安全机制 5. annocation ...

  9. 如何鉴别程序抄袭c语言程序代写

    如何鉴别程序抄袭:如何鉴别一份程序代码是抄袭另一份程序.输入:两个C语言源程序文件 输出:抄袭了多少?给出最相似的片段,判断是谁抄袭了谁? 提示:首先进行统一规范化排版,去掉无谓的空格.空行,然后比对 ...

随机推荐

  1. Cocos2d-x v3.6制作射箭游戏(二)

    原文 Cocos2d-x v3.6制作射箭游戏(二) 六 24, 2015by RENSHANin COCOS2D-X 上章我们创建并加载了游戏地图,接下来的两章我们将实现如下的效果. 在开始之前,先 ...

  2. linux知识点总结与随笔(关注linux爱好者公众号的一些笔记)

    sysdig工具,可以有strace ,tcpdump,lsof的功能. 前台任务与后台任务,知识点:test.sh &,Ctrl+z,bg,shopt grep |huponexit(sho ...

  3. [原] XAF ListView显示隐藏Footer菜单

    using System; using DevExpress.ExpressApp; using DevExpress.ExpressApp.Win.Editors; using DevExpress ...

  4. SVM 简要推导过程

    SVM 是一块很大的内容,网上有写得非常精彩的博客.这篇博客目的不是详细阐述每一个理论和细节,而在于在不丢失重要推导步骤的条件下从宏观上把握 SVM 的思路. 1. 问题由来 SVM (支持向量机) ...

  5. Android--入门

    之前自己在学校写过一些安卓应用,那时候没有系统地学过安卓,用到什么就网上找博客.找Demo,然后自己跟着敲一遍,有些东西也不太理解,现在打算做android开发这一块了,趁毕业之前赶紧多学些技术.先是 ...

  6. 用c#开发微信 (6) 微渠道 - 推广渠道管理系统 1 基础架构搭建

    我们可以使用微信的“生成带参数二维码接口”和 “用户管理接口”,来实现生成能标识不同推广渠道的二维码,记录分配给不同推广渠道二维码被扫描的信息.这样就可以统计和分析不同推广渠道的推广效果. 本系统使用 ...

  7. dotnet run是如何启动asp.net core站点的

    在曾经的 asp.net 5 过渡时期,运行 asp.net 5 站点的命令是dnx web:在如今即将到来的 asp.net core 时代,运行 asp.net core 站点的命令是dotnet ...

  8. 设计模式之美:Creational Patterns(创建型模式)

    创建型模式(Creational Patterns)抽象了对象实例化过程. 它们帮助一个系统独立于如何创建.组合和表示它的那些对象. 一个类创建型模式使用继承改变被实例化的类. 一个对象创建型模式将实 ...

  9. C语言 栈 链式结构 实现

    一个C语言链式结构实现的栈 mStack (GCC编译). /** * @brief C语言实现的链式结构类型的栈 * @author wid * @date 2013-10-30 * * @note ...

  10. 在express站点中使用ejs模板引擎

    在express站点中使用ejs模板引擎 文/玄魂 目录 在express站点中使用ejs模板引擎 前言 1.1         安装 1.2修改app.js 1.3创建测试页面 前言 使用 vs创建 ...