Simplified Fraction
St. Patrick Convent organizes a project exhibition "Innovative Minds" every year with an objective to provide the platform and unleash the potential of the students by showcasing their innovative projects. Pasha is a smart high school student and was eager to participate in the fair for the first time.
After a lot of ground works, she decided her project and set out to design the same. Her project requirement was to design an advanced calculator that has a fraction feature that will simplify fractions. The project will accept a non-negative integer as a numerator and a positive integer as a denominator and outputs the fraction in simplest form. That is, the fraction cannot be reduced any further, and the numerator will be less than the denominator.
Help Pasha to program her advanced calculator and succeed in her first ever project presentation. You can assume that all input numerators and denominators will produce valid fractions.
Hence create a class named Fraction with the following method.
Method Name | Description |
void printValue(int,int) | This method should display the fraction in simplest form. |
Input Format:
First line of the input is a non-negative integer which is the numerator in the fraction.
Second line of the input is a positive integer which is thedenominator in the fraction.
Output Format:
Output the simplified form of the fraction in a single line.
Refer sample input and output for formatting specifications.
Sample Input 1:
28
7
Sample Output 1:
4
Sample Input 2:
13
5
Sample Output 2:
2 3/5
SUM OF AN ARRAY
Sum of an array
Write a program to find the sum of the elements in an array using for each loop.
Input Format:
Input consists of n+1 integers. The first integer corresponds to ‘n’ , the size of the array. The next ‘n’ integers correspond to the elements in the array. Assume that the maximum value of n is 15.
Output Format:
Refer sample output for details.
All text in bold corresponds to the input and remaining corresponds to the output.
Sample Input 1:
Enter n :
5
2
3
6
8
1
Sample Output 1:
Sum of array elements is : 20
Sample Input 2:
Enter n :
4
5
9
45
14
Sample Output 2:
Sum of array elements is : 73
Problem Requirements:
Java
Keyword | Min Count | Max Count |
for | 1 | 2 |
COMMAND LINE ARGUMENT - PRINT STRING
Command Line Argument - Print String
Write a program to accept a string as a command-line argument and print the same.
Sample Input (Command Line Argument) 1:
Programming
Sample Output 1:
Programming - Command Line Arguments
Sample Input (Command Line Argument) 2:
Arguments
Sample Output 2:
Arguments - Command Line Arguments
Strictly adhere to the object oriented specifications given as a part of the problem statement.
Follow the naming conventions as mentioned. Create separate classes in separate files.]
Write a program to display the details based on the payment mode used for ticket booking using method overloading.
Create class Ticket Booking and overload the makePayment( ) method as follows,
Method
Based on the payment mode, get the payment mode details and call the corresponding method and display the payment details.
Refer sample input and output for formatting specifications.
All text in bold corresponds to the input and the rest corresponds to output.
Sample Input and Output 1:
Enter the mode of Payment:
1.Cash Payment
2.Wallet Payment
3.Credit Card
1
Enter the Amount of Payment:
5000
You have selected the Cash payment mode
The Amount is Rs.5000
Sample Input and Output 2:
Enter the mode of Payment:
1.Cash Payment
2.Wallet Payment
3.Credit Card
2
Enter the Wallet Number:
GRB1083
Enter the Amount of Payment:
2000
You have selected the Wallet payment mode
Wallet Number: GRB1083
The Amount is Rs.2000
Sample Input and Output 3:
Enter the mode of Payment:
1.Cash Payment
2.Wallet Payment
3.Credit Card
3
Enter the Credit Card Number:
5105105105105100
Enter the Validity Date(dd/MM/yyyy):
25/11/2020
Enter the Card Holder Name:
John Kennedy
Enter the Amount of Payment:
50000
You have selected the Credit Card payment mode
CreditCard Number:5105105105105100
Validity Date:25/11/2020
Card Holder Name: John Kennedy
The Amount is Rs.50000
Sample Input and Output 4:
Enter the mode of Payment:
1.Cash Payment
2.Wallet Payment
3.Credit Card
4
Please select the correct mode of payment...