Starting from:

$29.99

ASSIGNMENT 4 Interactive programs

COMPUTER SCIENCE 11A 
PROGRAMMING IN JAVA
PROGRAMMING ASSIGNMENT 4
Overview:
This assignment will give you practice with interactive programs, for loops, if/else
statements, methods that return values, and everything covered so far.
Modularity in your code is very important, YOU MUST USE STATIC METHODS.
Problem 1
Write a program that reads a binary number as a string from the keyboard and then converts it
into a decimal number. For example, if the input is 11000 the output should be 24.
Problem 2
Write a program that produces the following output:
***** ////////// *****
**** ////////\\ ****
*** //////\\\\ ***
** ////\\\\\\ **
* //\\\\\\\\ *
 \\\\\\\\\\
Problem 3
Write a program that reads a positive integer value, and compute the following sequence:
o If the value is even, halve it.
o If it's odd, multiply by 3 and add 1.
o Repeat this process until the value is 1, printing out each value.
o Finally print out how many of these operations you performed.
Note: If the input value is less than 1, print a message containing the word Error and exit the
program.
This is how the output should look like:
Initial value is: 9
Next value is: 28
Next value is: 14
Next value is: 7
Next value is: 22
Next value is: 11
Next value is: 34
Next value is: 17
Next value is: 52
Next value is: 26
Next value is: 13
Next value is: 40
Next value is: 20
Next value is: 10
Next value is: 5
Next value is: 16
Next value is: 8
Next value is: 4
Next value is: 2
Final value 1, number of operations performed 19
Problem 4
Write a program that prompts for a date (month, day, year) and reports the day of the week for that
date. It might be helpful to know that January 1, 1601 was a Monday.
Problem 5
Write a program that prompts for a number (not bigger than 4999) and displays it in Roman
numerals.
Problem 6
Write a program that prompts for two people’s birthday (month and day), along with today’s month
and day. The program should figure out how many days remain until each user’s birthday and
which birthday is sooner.
Guidelines:
For this assignment you should limit yourself to the Java features covered in class so far (lecture
19).
Grading:
You will be graded on
o External Correctness: The output of your program should match exactly what is expected.
Programs that do not compile will not receive points for external correctness.
o Internal Correctness: Your source code should follow the stylistic guidelines shown in
class. Also, remember to include the comment header at the beginning of your program.
Submission:
Create a folder named PA4 containing all your java files. Name your java files
Problem1.java, Problem2.java, etc. Zip the folder, and submit it via Latte the day it is due,
Sun, Oct 23 at 11:00pm.

More products