首页
编程语言
数据库
网络开发
Algorithm算法
移动开发
系统相关
金融统计
人工智能
其他
首页
>
> 详细
CS102A留学生辅导、java编程调试、讲解java设计、辅导program 辅导Python编程|辅导留学生 Statistics统计、
2019S CS102A Assignment 2
A2Q1: Chinese Lunar year[20 points]
Please write a program to show the Chinese Lunar year of Stems-and-Branches() according to the year number, and the animal symbol() of the year which a person was born in.
The Stems-and-Branches uses 10 Stems called:jia, yi, bing, ding, wu, ji, geng, xin, ren, and gui(), and 12 Branches called zi, chou, yin, mao, chen, si, wu, wei, shen, you, xu and hai().Combining each of the10 Stems with one of the 12 Branches in sequence creates 60 chronological symbols.For example jiazi, yichou, bingyin, etc. These 60 symbols are used in circles and thus each year has a chronological symbol. And the Branches also represents the animal symbol of Rat, Ox, Tiger, Rabbit, Dragon, Snake, Horse, Sheep, Monkey, Rooster, Dog, Pig. For example, it is the year of JiHai() in 2019. And it is the year of Pig.
Search on web how to calculate it. And write a program using switch statement.
Tips:
(1)Remainder=Year%10, {(Stems:remainder) }={(jia:4)}{(yi:5)}(bing:6)(ding:7)(wu:8)(ji:9)(geng:0)(xin:1)(ren:2)(gui:3)
(2)Remainder=Year%12
{(Branches:remainder) }={(zi:4)}{(chou:5)}{(yin:6)}{(mao:7)}{(chen:8)}{(si:9)}{(wu:10)}{(wei:11)}{(shen:0)}{(you:1)}{(xu:2)}{(hai:3)}
(3)Branches and animal pair
{(zi:Rat)}{(chou:Ox)}{(yin:Tigger)}{(mao:Rabbit)}{(chen:Dragon)}{(si:Snake)}{(wu:Horse)}{(wei:Sheep)}{(shen:Monkey)}{(you:Rooster)}{(xu:Dog)}{(hai:Pig)}
ref: http://baijiahao.baidu.com/s?id=1543800345816500
Sample output:
Sample code:
public class A2Q1 {
public static void main(String[] args){
int year = Integer.parseInt(args[0]);
//define the array of Stems-and-Branches, animal symbols
String stem[] = ;
String branch[] = ;
String animal[] = ;
// to calculate
// output
System.out.printf("%s is the year of %s-%s. Also %s year.",...);
}
}
A2Q2: Simple Statistic of number sequence [30 points]
Write a program to calculate the average(), mode() and median() of a sequence of numbers.
The average of the numbers is the sum divided by count. The mode is the number appears most frequently. There may be more than 1 mode in a number sequence. The median is the number at “Middle” position of the sequence after sorting. The median is at the “Middle” position of (n-1)/2+1 when n is odd, or is the average value of numbers at position of n/2 and n/2+1.
Using Array and for statement.
(1)Calculate the average;
(2)Count the numbers and find the number appears max times;
(3)Sort all numbers from small to big, and find the “Middle”;
Tips: args.length shows how many parameters inputted.
Sample output:
Sample code:
public class A2Q2 {
public static void main(String[] args){
double number[];
double average = 0.0;
double mode = 0.0;
double median = 0.0;
number = new double[args.length];
//1. to get the input numbers and store in array
for (int i=0; i
}
//2. average
double sum=0.0;
System.out.printf("average = %.2f\n",average);
//3. count numbers
int count[] = new int[args.length];
for (int i=0; i
count[i]=1;
}
for (int i=0; i
}
int maxCount=0;
//3.1 find the max count
for (int i=0; i
}
//3.2 find the mode with max count
System.out.print("mode = ");
//4.1 sorting
for (int i=0; i
for (int j=0; j
}
}
// 4.2 median
System.out.printf("\nmedian = %.2f",median);
}
}
A2Q3: Grading system [20 points]
Please write 2 programs to calculate the GPA at SUSTech:
(1)A2Q3_1:Input a score of letter grading, and to calculate the Grade Point.
Tips: string.CharAt(int index) returns the value of the character at the specified index of the string
(2)A2Q3_2:Input a serials of percentage grading and credit hour, and to calculate the GPA.
Sample output:
Sample code:
public class A2Q3_2 {
public static void main(String[] args){
double score[];
int credit[];
if (0==args.length || 0 != args.length%2){
System.out.println("Please input the right format of score and credit hour in pair, eg. 95 2 88 3");
return;
}
score = new double[args.length/2];
credit = new int[args.length/2];
// to get the input numbers and store in array
for (int i=0; i
}
// calculate GP
double GP[] = new double[args.length/2];
for (int i=0; i
}
double GPA=0.0;
System.out.printf("GPA = %.2f",GPA);
}
}
Question 4: Calculate [30 points]
Write a program using basic arrays to calculate the value of an arithmetic expression consisting of numbers( could be floating-point) and operators +,-,*and / . The arithmetic expression is passed to the program from the command line as a string.
Tips:
(1)We can assume that the input string always represents a valid arithmetic expression;
(2)Only 3 numbers and 2 operators;maybe with a pair of bracket;
Sample output:
Sample code:
public class A2Q4 {
public static void main(String[] args) {
//if (0 == args.length) return;
int n = args[0].length();
double num[] = new double[3];//
char cal[] = new char[2];//
int nums = 0;
int cals = 0;
String strNumber = "";
//to parse the string
for (int i = 0; i < n; i++) {
//System.out.print(args[0].charAt(i));
switch (args[0].charAt(i)) {
case '+':
// to do youself
break;
case '-':
// to do youself
break;
case '*':
// to do youself
break;
case '/':
// to do youself
break;
default:
// to do youself
break;
}
//System.out.print(nums+","+cals);
}
// to calculate
double result = 0.0;
if (('+' == cal[0] || '-' == cal[0]) && ('*' == cal[1] || '/' == cal[1])){
// to finish
}
else
{
// to finish
}
// to print result
System.out.printf("%s=%.2f", args[0], result);
}
}
Rules
1.Please submit “.java” file of these five questions.
2.The class name of each “.java” file should be A2Q1, A2Q2, A2Q3_1,A2Q3_2 , A2Q4 respectively to represent these five questions.
3.No Chinese characters are allowed to appear in your code.
4.No package included.
5.The arguments and the output must strictly follow the description of each question.
6.Please submit your assignment on the SAKAI site of your lab section. Marks will be deducted if you submit later than the deadline. If you submit your assignment within 24 hours after the deadline (grace period), your score will be half of the score you could get if the submission was made before the deadline. Assignments submitted after the grace period will not be graded (meaning you will get a zero for the assignment).
联系我们
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-21:00
微信:codinghelp
热点文章
更多
辅导 comm2000 creating socia...
2026-01-08
讲解 isen1000 – introductio...
2026-01-08
讲解 cme213 radix sort讲解 c...
2026-01-08
辅导 csc370 database讲解 迭代
2026-01-08
讲解 ca2401 a list of colleg...
2026-01-08
讲解 nfe2140 midi scale play...
2026-01-08
讲解 ca2401 the universal li...
2026-01-08
辅导 engg7302 advanced compu...
2026-01-08
辅导 comp331/557 – class te...
2026-01-08
讲解 soft2412 comp9412 exam辅...
2026-01-08
讲解 scenario # 1 honesty讲解...
2026-01-08
讲解 002499 accounting infor...
2026-01-08
讲解 comp9313 2021t3 project...
2026-01-08
讲解 stat1201 analysis of sc...
2026-01-08
辅导 stat5611: statistical m...
2026-01-08
辅导 mth2010-mth2015 - multi...
2026-01-08
辅导 eeet2387 switched mode ...
2026-01-08
讲解 an online payment servi...
2026-01-08
讲解 textfilter辅导 r语言
2026-01-08
讲解 rutgers ece 434 linux o...
2026-01-08
热点标签
mktg2509
csci 2600
38170
lng302
csse3010
phas3226
77938
arch1162
engn4536/engn6536
acx5903
comp151101
phl245
cse12
comp9312
stat3016/6016
phas0038
comp2140
6qqmb312
xjco3011
rest0005
ematm0051
5qqmn219
lubs5062m
eee8155
cege0100
eap033
artd1109
mat246
etc3430
ecmm462
mis102
inft6800
ddes9903
comp6521
comp9517
comp3331/9331
comp4337
comp6008
comp9414
bu.231.790.81
man00150m
csb352h
math1041
eengm4100
isys1002
08
6057cem
mktg3504
mthm036
mtrx1701
mth3241
eeee3086
cmp-7038b
cmp-7000a
ints4010
econ2151
infs5710
fins5516
fin3309
fins5510
gsoe9340
math2007
math2036
soee5010
mark3088
infs3605
elec9714
comp2271
ma214
comp2211
infs3604
600426
sit254
acct3091
bbt405
msin0116
com107/com113
mark5826
sit120
comp9021
eco2101
eeen40700
cs253
ece3114
ecmm447
chns3000
math377
itd102
comp9444
comp(2041|9044)
econ0060
econ7230
mgt001371
ecs-323
cs6250
mgdi60012
mdia2012
comm221001
comm5000
ma1008
engl642
econ241
com333
math367
mis201
nbs-7041x
meek16104
econ2003
comm1190
mbas902
comp-1027
dpst1091
comp7315
eppd1033
m06
ee3025
msci231
bb113/bbs1063
fc709
comp3425
comp9417
econ42915
cb9101
math1102e
chme0017
fc307
mkt60104
5522usst
litr1-uc6201.200
ee1102
cosc2803
math39512
omp9727
int2067/int5051
bsb151
mgt253
fc021
babs2202
mis2002s
phya21
18-213
cege0012
mdia1002
math38032
mech5125
07
cisc102
mgx3110
cs240
11175
fin3020s
eco3420
ictten622
comp9727
cpt111
de114102d
mgm320h5s
bafi1019
math21112
efim20036
mn-3503
fins5568
110.807
bcpm000028
info6030
bma0092
bcpm0054
math20212
ce335
cs365
cenv6141
ftec5580
math2010
ec3450
comm1170
ecmt1010
csci-ua.0480-003
econ12-200
ib3960
ectb60h3f
cs247—assignment
tk3163
ics3u
ib3j80
comp20008
comp9334
eppd1063
acct2343
cct109
isys1055/3412
math350-real
math2014
eec180
stat141b
econ2101
msinm014/msing014/msing014b
fit2004
comp643
bu1002
cm2030
联系我们
- QQ: 99515681 微信:codinghelp
© 2024
www.7daixie.com
站长地图
程序辅导网!