0% found this document useful (0 votes)
18 views3 pages

Java Math App with Loops Guide

The document outlines a Java lab activity where students create a terminal-based Math App that utilizes loops and user input for various computations. The app must present a menu of eight mathematical operations, handle user selections, and allow for repeated calculations until the user decides to exit. Submission requires saving the code as MathApp.java, uploading it to GitHub, and providing screenshots of test runs.

Uploaded by

kinsleynacua820
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views3 pages

Java Math App with Loops Guide

The document outlines a Java lab activity where students create a terminal-based Math App that utilizes loops and user input for various computations. The app must present a menu of eight mathematical operations, handle user selections, and allow for repeated calculations until the user decides to exit. Submission requires saving the code as MathApp.java, uploading it to GitHub, and providing screenshots of test runs.

Uploaded by

kinsleynacua820
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Java Lab Activity: Math App with Loops

(Terminal Version)
Engr. Jamie Eduardo Rosal, MSCpE

Objective

By the end of this activity, students will:

1.​ Apply loops to repeatedly run user-selected computations.​

2.​ Practice using the Scanner class for input.​

3.​ Strengthen decision-making using if-else or switch-case statements.​

Activity Description

You will create a Math App in Java that runs entirely in the terminal. The program should:

1.​ Display a menu with 8 different mathematical computations.​

2.​ Accept user input to select which computation to perform.​

3.​ Perform the computation based on user input.​

4.​ Display the result.​

5.​ Ask the user if they want to perform another computation.​

○​ If Yes, show the menu again.​

○​ If No, terminate the program with a thank-you message.​


Step 1 – Menu Example

The menu might look like this (you can choose your own 8 computations):

=== Math App Menu ===​


1. Addition of two numbers​
2. Subtraction of two numbers​
3. Multiplication of two numbers​
4. Division of two numbers​
5. Factorial of a number​
6. Power (x^y)​
7. Sum of numbers 1 to N​
8. Check if a number is prime​
0. Exit

Step 2 – Example Flow


=== Math App Menu ===​
1. Addition of two numbers​
2. Subtraction of two numbers​
3. Multiplication of two numbers​
4. Division of two numbers​
5. Factorial of a number​
6. Power (x^y)​
7. Sum of numbers 1 to N​
8. Check if a number is prime​
0. Exit​
Enter your choice: 1​

Enter first number: 10​
Enter second number: 5​
Result: 15​

Do you want to perform another computation? (yes/no): yes

Then the menu displays again until the user types no or selects 0. Exit.

Step 3 – Core Requirements


●​ Must use a loop (e.g., while or do-while) to keep showing the menu.​

●​ Must use if-else or switch-case to handle menu choices.​

●​ Must implement 8 computations (programmer’s choice, examples given above).​

●​ Must handle invalid inputs gracefully (e.g., divide by zero, negative factorial, etc.).​

Submission Instructions

1.​ Save your program as [Link]. ​

Upload your code to GitHub in a repository named:​



MathApp_LastName_FirstName

2.​ Include at least two screenshots of test runs (one with normal inputs, one showing error
handling or edge cases).​

3.​ Submit the GitHub repository link to your instructor.

You might also like