首页 > > 详细

Java辅导门级编程,辅导 prepared by Chris Trathen辅导留学生Java语言

Introduction
5java,,,,
Requirement
CSE105 CW1 1
CSE105 Introduction to Programming in Java, 2016
Assignment 1, prepared by Chris Trathen
Instruction
(1) There are 5 questions for the first assignment. Each question is worth 20 marks. The
assignment is worth 15% of the total mark for CSE105.
(2) Plagiarism will be very closely monitored. You should be very cautious when you discuss
with classmates. Two similar answers will all get zeros marks or more serious consequences.
After the marking, some of the students will be interviewed to confirm their independence in the
completion of the assignments.
(3) The deadline for submission of Assignment 1 is: 6:00pm, October 16, 2016 Sunday. You
should pack all of your code with WinRAR, using your student ID as the file name and then
upload it to ICE. The uploading link will be automatically stopped after 6:00pm.
Question 1
The factorial function of a positive integer n is the product of all the integers from 1 to n. For
example, the factorial of 5 is 1x2x3x4x5 = 120. This is usually expressed as 5!=120. By
definition 0!=1. Write a program that calculates the factorial n!.
Write a program that accepts as input a number between 0 and 20 and calculates the factorial of
that number.
Question 2
Write a program that prints a table of temperature conversion from Celsius to Fahrenheit. For
example:
Celsius Fahrenheit
100 212
5 41
…………
-5 23
The exact range of data used is your choice. This is example only.
Use the formula F = C 9 / 5 + 32
Perform. the calculation using floating point arithmetic, but display the results as the closest
integer.
CSE105 CW1 2
Question 3
Write a program that analyses a triangle. Input the length of 3 sides of a triangle from the
keyboard.
Firstly, reject any input that does not represent a triangle.
Then determine whether the triangle is:
 Equilateral - all sides the same length
 Isosceles - two sides the same length
 Scalene - no sides the same length
CSE105 CW1 3
Question 4
A leap year is a year with 366 days. A leap year has the 29 th February. A year is a leap year if it is
divisible by 4 except for the century years (divisible by 100). Century years are only leap years if they are
divisible by 400. Write a program that accepts a year and determines if it is a leap year.
Use a separate method to test if a year is a leap year.
The following information will help when you test your program. The leap years 1800 to 2400:
1804 1904 2004 2104 2204 2304
1808 1908 2008 2108 2208 2308
1812 1912 2012 2112 2212 2312
1816 1916 2016 2116 2216 2316
1820 1920 2020 2120 2220 2320
1824 1924 2024 2124 2224 2324
1828 1928 2028 2128 2228 2328
1832 1932 2032 2132 2232 2332
1836 1936 2036 2136 2236 2336
1840 1940 2040 2140 2240 2340
1844 1944 2044 2144 2244 2344
1848 1948 2048 2148 2248 2348
1852 1952 2052 2152 2252 2352
1856 1956 2056 2156 2256 2356
1860 1960 2060 2160 2260 2360
1864 1964 2064 2164 2264 2364
1868 1968 2068 2168 2268 2368
1872 1972 2072 2172 2272 2372
1876 1976 2076 2176 2276 2376
1880 1980 2080 2180 2280 2380
1884 1984 2084 2184 2284 2384
1888 1988 2088 2188 2288 2388
1892 1992 2092 2192 2292 2392
1896 1996 2096 2196 2296 2396
2000
2400
CSE105 CW1 4
Question 5
Write Java program to check if a number is Armstrong number.
An Armstrong number of 3 digit is a number for which sum of cube of its digits are equal to the
number.
Examples:
371 is an Armstrong number because 333 + 777 + 111 = 371.
123 is not an Armstrong number because 111 + 222 + 33*3 = 36.
This assignment is individual work. Plagiarism (e.g. copying materials from other
sources without proper acknowledgement) is a serious academic offence. Plagiarism
will not be tolerated and will be dealt with in accordance with the University Code of
Practice on Assessment.

 

联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!