Java Reference
In-Depth Information
7. Write a program that allows the user to enter the last names of five
candidates in a local election and the votes received by each candidate.
The program should then output each candidate's name, the votes received
by that candidate, and the percentage of the total votes received by the
candidate. Your program should also output the winner of the election. A
sample output is:
Candidate
Votes Received
% of Total Votes
Johnson
5000
25.91
Miller
4000
20.73
Duffy
6000
31.09
Robinson
2500
12.95
Ashtony
1800
9.33
Total 19300
The Winner of the Election is Duffy.
8. Write a program that allows the user to enter students' names followed by
their test scores and outputs the following information (assume that the
maximum number of students in the class is 50):
a. Class average
b. Names of all the students whose test scores are below the class average,
with an appropriate message
c. Highest test score and the names of all the students having the highest
score
Programming Exercise 15, in Chapter 7, asks you to find the mean and
standard deviation of five numbers. Extend this programming exercise to
find the mean and standard deviation of up to 100 numbers. Suppose that
the mean (average) of n numbers x 1 , x 2 , ..., x n is x. Then the standard
deviation of these numbers is:
9.
9
r
ðx 1 2 þðx 2 2 þþðx i 2 þþðx n 2
n
s ¼
:
(Adding Large Integers) In Java, the largest int value is 2147483647 .So
an integer larger than this cannot be stored and processed as an integer.
Similarly, if the sum or product of two positive integers is greater than
2147483647 , then the result will be incorrect. One way to store and
manipulate large integers is to store each individual digit of the number in
an array. Write a program that inputs two positives and outputs the sum of
the numbers. Your program must contain a method to find and output the
sum of the numbers. (Hint: Read numbers as strings and store the digits of
the number in the reverse order.)
10.
Search WWH ::




Custom Search