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. Splunk及splunkforward简单部署配置

    部署环境 操作系统 服务器操作系统版本:CentOS release 6.5 (Final) 2.6.32-431.el6.x86_64 软件 软件版本:splunk-6.4.0 tar: splun ...

  2. Spring <context:annotation-config/> 解说

    在基于主机方式配置Spring的配置文件中,你可能会见到<context:annotation-config/>这样一条配置,他的作用是式地向 Spring 容器注册 AutowiredA ...

  3. C#分布式缓存一:Couchbase的安装与简单使用

    一.简介 目前C#业界使用得最多的 Cache 系统主要是 Memcached和 Redis. 这两个 Cache 系统可以说是比较成熟的解决方案,也是很多系统当然的选择. Memcache的开发团队 ...

  4. Docker学习笔记整理

    Docker接触有一段时间了,但是对于Docker的使用可以说是一点不会.现在要在Docker上部署基于Angular开发的页面.只能一点点积累查找的资料,顺手整理一下,方便后面的回顾. 其中用到的资 ...

  5. PDB调试Python程序

    pdb是python内置的调试工具, 它可以在终端中调试Python程序, 这允许pdb在很多无法安装IDE的服务器上使用. 虽然远程调试使用广泛, 但在必要的时候(比如难以在本地搭建运行环境)pdb ...

  6. 那些年我们一起追过的Linux命令

    1. cd - 作用:返回上次的目录,类似于Windows的后退功能: 2. man ascii 作用:打印出八进制.十六进制和十进制的ASCII码表:(再也不用Google ASCII表啦) 3. ...

  7. Django时间查询

    1.gt:大于某个时间now = datetime.datetime.now()#前一天start = now – datetime.timedelta(hours=23, minutes=59, s ...

  8. Java程序员的日常 —— static的用法讲解实践

    之前文章说过Java中static的作用,有朋友想看个例子.于是便抽空写了个小栗子 代码 package xing.test.thinking.chap5; class A{ public A() { ...

  9. .NET通过RFC读取SAP数据

    本篇文章中我主要讲的是.NET如何通过RFC从SAP中读取数据.为了功能的可复用性,我将调用RFC的代码从业务层中分离出来单独建立在一个namespace中. 当然除了需要我们自己编写代码以外,还需要 ...

  10. atitit.android模拟器使用报告

    atitit.android模拟器使用报告 靠谱助手 仅仅7--15M,只助手,没android模拟器.. BlueStacks新版本App Player采用名为Layercake的技术,可以让针对A ...