 # 代写C代码 代做C程序 C辅导 C家教

## 微信: ittutor QQ: 14061936 Email: ittutor@qq.com

### 导航

ture notes but everybody must do his/her work

2)      If I need, I will ask student how he/she has solved the problem. If I do not get adequate answer I will assume that answer is not yours.

3)      I am giving you 12 hrs time period from 7:00 am to 7:00 pm

4)      Submit all your works through blackboard just like a lab

5)      You must write java code for every problem.

Part 1: Loop

1)      (15 pts) Write a loop statement to print the following triangle for any given integer n

1

1       2

1      2       3

…………………………

1 2       …      n-1   n

Note: Look at the example on the blackboard (Mar4 file name diamond)

Part II: Method writing

2)      (15 pts) Implement a method called sumIndex which takes an integer number, say N, and returns summation of digits of N.

Example: int N=1002035

sumIndex(N) returns  11

3)       (15 pts) Implement a method called numberCount which takes an array of non-negative integers  from 0 to 9, and determines how many times each element is repeated in given array and prints them:

Example:  int a[]={1,2,2,3,4,5,2,1,4,4,5,2};

numberCount(a)

#1’s : 2

#2’s:  4

#3’s:  1

#4’s:  3

#5’s:  2

Note: Similar lecture note is on the blackboard.

Section 2: Complete program writing

Problem: (55 pts) Given integer N is divisible by three if summation of digits of N is divisible by 3. For example

N=12 is divisible by 3 because 1+2=3 is divisible by 3. N=111 is divisible by 3 because 1+1+1=3 is divisible by 3. Write a program that reads M numbers of integers (determined by user) and determines if they are divisible by 3 or not. Your code also determines how many number out of M are divisible by 3.

Note: you should use the method in problem 2.

Example: For example M=7 and user entered the following 7 numbers: 12, 13, 14, 102, 104, 222, 100101. Then java program outputs the following:

1-12          yes

2-13          no

3-14          no

4-102                 yes

5-104                 no

6-222                 yes

7-100101          yes

Total input numbers divisible by 3 is: 4