Computer Science Courses
Related sites
Lab 2 |
Write a few small Java programs which require to useconditional structures, operators and loops.
Write a program to print out the last digit of an integerseven times the value of an integer which the user enters.
For example, if a user enters the number '53', your programwill compute the number 7*53=371 and print out the last digitwhich is '1'.
(Note that you will need to use the modulo operator (%) in this program.)
0-50 F51-60 E61-70 D71-80 C81-90 B91-100 AWrite a program that asks for a score (0-100) and reports the grade (F-A).
Refine the previous program by making it to add a '+' or '-' after the grades E and above according to last digit as follows:
1-3 -4-7 8-0 +
This means that a mark of 93 is A-; 88 is B+; 65 is D and so on.
Write a program that asks the user for a positive integer n andprints out the n×n grid like this (when n is 4):
+--+--+--+| | | |+--+--+--+| | | |+--+--+--+| | | |+--+--+--+
You should have one method to print the even rows and one method to print the odd rows.
+ /| / | / |+---+
Different functionalities of your programs (like calculating a desirednumber, or determining a grade, or printing a result etc), should be implemented with the help of different methods: this is calledmodularization — one of the basic principles of programming.If you did not use methods in our coding solutions, but lumped everythinginto one main method, then re-implement everything usingmodularization.
Lab 2 |
Updated: Sun 12 Jun 2016 17:27:37 AEST • Responsible Officer: JavaScript must be enabled to display this email address. • Page Contact:
+61 2 6125 5111
The Australian National University, Canberra
CRICOS Provider : 00120C ABN : 52 234 063 906