Fourth Lab
Learning Objective(s)
- Learn the for loop
- Be able nest loops
- Be able to format output well
- Use a switch statement
- Learn something on your own.
Overview of the Program
This lab involves creating an arithmetic table. You are to allow the user to specify which operation (+, -, *, /) and the size of the table.
Specifics
Major components
- The program should be called Tables
- The user will input a letter/word indicating which operation (add, subtract, multiply, divide). But they may misspell it and/or allowed to use upper or lower case letters. So only use the first letter.
- Use integer arithmetic for all the operations.
- The user can specify the size of the table (up to 99)
- The table must be nicely aligned
Things to learn on your own
Google can be a significant help here. Also, your textbooks can help.
- How to get the first letter of the string
- How to format the output with a variable amount of spaces
Sample output
Simplest sample result if it is an addition table for 1 - 5 is as follows. Feel free to make your table even nicer if you want.
+ 1 2 3 4 5
1 2 3 4 5 6
2 3 4 5 6 7
3 4 5 6 7 8
4 5 6 7 8 9
5 6 7 8 9 10
Submission
- Create an empty zip folder.
- Place your program (.java file) in it
- Place your software development report in it.
- Submit the zip folder on canvas
Optional improvements
- Add an additional operation
- Allow for floating point in the division (outputting at most 3 digits are the decimal point)
- Work in base 8 (doing all base work yourself). This is a MAJOR challenge and is only included for those that are extremely bored!