- Program 1 Practice Writing Static Methods And Calling Static Methods From The Main Method Given A File With Different 1 (274.56 KiB) Viewed 37 times
Program 1: Practice writing static methods and calling static methods from the main method. Given a file with different
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
Program 1: Practice writing static methods and calling static methods from the main method. Given a file with different
Program 1: Practice writing static methods and calling static methods from the main method. Given a file with different integer N values listed (one number per line), calculating the following arithmetic expressions and output to an output file. Each of the following computations should be organized into separate methods. Factorial Method: This method takes in 1 input n and calculates the factorial value for that number. The output should print the message: The factorial of is For example, 3! = 3 * 2 * 1 Sum of squares Method: This method takes in 1 input n and calculates the sum of the squares for the number series ending in that number. The output should print the message: The sum of squares is For example, 3 will yield 1+4+9 = 14 Fibonacci sequence Method: This method takes in 1 input n and prints the fibonacci sequence for n elements of the sequence. Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... Program 2: Practice expressing control flow using conditionals. This program builds upon your work from homework 1. Using standard stream input, prompt the user to choose an option for a shape. Then, depending on the shape, ask for the relevant parameters (i.e. radius, width, length) and output the area and either of circumference or perimeter for that shape. Program 3: Practice time-based calculations. Build an age calculator that takes in a list of values from an input file that contains Month, Day, and Year - calculate the appropriate age for each record from the values in the line. A record is one line in the input file. Please don't forget to: Write clean code - Indent code consistently, use meaningful variable names, space out code for readability. Include comments with your code explaining your logic and rationale Create your own input files - approximately 5-10 lines per input file is fine Do not submit the *.class files in your repository Write out instructions for running your code - if I cannot easily figure out how to run your program you will get a 0 ● ● Test run your program before submitting (with sample demonstration) - full points reserved only for implementations that can be run without issues from the terminal environment with the expected results