Description: In the main program create a menu system that will allow a user to choose from 3 option. 1. Fraction calculator 2. Grading schema 3. Biggest integer
Program #1 Fraction calculator: You will start by prompting the user for two fractions in the main. The inputs should be two strings in the form #/#. You must account for both positive and negative numerators. Therefor -#/# is also a valid input. In a separate function create a program that will calculate the following. Addition, Subtraction, Multiplication and Division of the two fractions. Then display the results in a formatted table. All outputted fractions must be in lowest terms or whole numbers if possible.
========================================================
Program name FractionCalculator.java
========================================================
import java.util.Scanner;
public class FractionCalculator {
public static void main(String[] args) {
int ch;
Scanner sc = new
Scanner(System.in);
String fraction1="";
String fraction2="";
while (true) {
System.out.println("Menu");
System.out.println("1. Fraction Calculator");
System.out.println("2. Grading schema");
System.out.println("3. Biggest integer");
System.out.println("4. Exit");
System.out.print("Enter your choice: ");
ch =
sc.nextInt();
if(ch!=4)
{
System.out.print("Enter Fraction 1: ");
fraction1 = sc.next();
System.out.print("Enter Fraction 2: ");
fraction2 = sc.next();
}
switch
(ch) {
case
1:
//Calling function
fractionCalculator(fraction1, fraction2);
break;
case
2:
System.out.println("Implementation In
Progress");
break;
case
3:
System.out.println("Implementation In
Progress");
break;
case
4:
break;
default:
System.out.println("Invalid choice");
}
if(ch==4)
break;
}
System.out.println("Thank
you!");
}
public static void fractionCalculator(String fraction1, String fraction2) {
int numerator1,
numerator2;
int denominator1, denominator2;
String addResult;
String subResult;
String mulResult;
String divResult;
String fraction1Split[]
= fraction1.split("/");
String fraction2Split[] =
fraction2.split("/");
// Extract numerator and
denominator
numerator1 =
Integer.parseInt(fraction1Split[0]);
denominator1 =
Integer.parseInt(fraction1Split[1]);
// Extract numerator and
denominator
numerator2 =
Integer.parseInt(fraction2Split[0]);
denominator2 =
Integer.parseInt(fraction2Split[1]);
// Logic for fractional
calculation
addResult = (numerator1 *
denominator2 + numerator2 * denominator1)+ "/" + (denominator1 *
denominator2);
subResult = (numerator1 *
denominator2 - numerator2 * denominator1)+ "/" + (denominator1 *
denominator2);
mulResult = (numerator1 *
numerator2) + "/"+ (denominator1 * denominator2);
divResult = (numerator1 *
denominator2) + "/"+ (denominator1 * numerator2);
System.out.println("------------------------------");
System.out.println("Addition Result : " + addResult);
System.out.println("Substraction
Result : " + subResult);
System.out.println("Multiplication
Result : " + mulResult);
System.out.println("Division Result
: " + divResult);
System.out.println("------------------------------");
}
}
Description: In the main program create a menu system that will allow a user to choose...
Create a procedure driven program for performing arithmetic with fractions. Using a switch statement in main to perform the various actions. Similar to this; Menu a) Load/Reload first fraction b) Load/Reload second fraction c) Add two fractions and display answer d) Subtract two fractions and display answer e) Multiply two fractions and display answer f) Divide two fractions and display answer g) Exit Provide functions that allow for The reloading of the fractions. The addition of two rational numbers. The...
Design a calculator program that will add, subtract, multiply, or divide two numbers input by a user.Your program should contain the following:-The main menu of your program is to continue to prompt the user for an arithmetic choice until the user enters a sentinel value to quit the calculatorprogram.-When the user chooses an arithmetic operation (i.e. addition) the operation is to continue to be performed (i.e. prompting the user for each number, displayingthe result, prompting the user to add two...
Write a Python Program that displays repeatedly a menu as shown in the sample run below. The user will enter 1, 2, 3, 4 or 5 for choosing addition, substation, multiplication, division or exit respectively. Then the user will be asked to enter the two numbers and the result for the operation selected will be displayed. After an operation is finished and output is displayed the menu is redisplayed, you may choose another operation or enter 5 to exit the...
Write a program that performs the following: 1. Presents the user a menu where they choose between: a. Add a new student to the class i. Prompts for first name, last name ii. If assignments already exist, ask user for new student’s scores to assignments b. Assign grades for a new assignment i. If students already exist, prompt user with student name, ask them for score ii. Students created after assignment will need to...
Develop a flowchart and then write a menu-driven C++ program that uses several FUNCTIONS to solve the following program. -Use Microsoft Visual C++ .NET 2010 Professional compiler using default compiler settings. -Use Microsoft Visio 2013 for developing your flowchart. -Adherence to the ANSI C++ required -Do not use <stdio.h> and <conio.h>. -Do not use any #define in your program. -No goto statements allowed. Upon execution of the program, the program displays a menu as shown below and the user is prompted to make a selection from the menu....
You have been developing a Fraction class for Teacher’s Pet Software that contains several fields and functions. a. Add four arithmetic operators, +, -, *, and /. Remember that to add or subtract two Fractions, you first must convert them to Fractions with a common denominator. You multiply two Fractions by multiplying the numerators and multiplying the denominators. You divide two Fractions by inverting the second Fraction, then multiplying. After any arithmetic operation, be sure the Fraction is in proper...
Your assignment is to create a restaurant ordering system where the cashier can create the menu and then take in the order and display the order back to the customer Sample Execution – Level 1 Welcome to your Menu Creation system. How many items would you like to have on your menu? 2 Create your menu! Enter item #1: Coffee Enter item #2: Tea This is the menu: Coffee Tea What would you like to order? Cake That isn’t on...
Write an ARM program that implements a simple four-function calculator and prompts the user to enter a pair of decimal integers (A and B) followed by a character that specifies one of the operators: ‘+’ for addition to compute A+B ‘-‘ for subtraction to compute A-B ‘*’ for multiplication to produce the product A*B ‘/’ for division to produce the quotient A/B. Input should be the pair of numbers followed by the operand followed by a return. For example...
DESCRIPTION Create a C++ program to manage phone contacts. The program will allow the user to add new phone contacts, display a list of all contacts, search for a specific contact by name, delete a specific contact. The program should provide the user with a console or command line choice menu about possible actions that they can perform. The choices should be the following: 1. Display list of all contacts. 2. Add a new contact. 3. Search for a contact...
CE – Return and Overload in C++ You are going to create a rudimentary calculator. The program should call a function to display a menu of three options: 1 – Integer Math 2 – Double Math 3 – Exit Program The program must test that the user enters in a valid menu option. If they do not, the program must display an error message and allow the user to reenter the selection. Once valid, the function must return the option...