In: Computer Science
Minimum of three shipment company quote - Code in Java
Ashok is a rice trader from India and he wanted to send his supplies to Singapore. There are 3 shipment companies near his godown and he decided to choose the shipping company which gives him the minimum quotation for shipping his supplies.
Given the shipping quotations of three different shipping companies for Ashok's rice supplies, write a program to find the minimum quotation.
Problem Specification :
The File name should be Main.java.
Input Format:
The first input consists of an integer that corresponds to the quotation from "Mediterranean Shipping Company".
The second input consists of an integer that corresponds to the quotaion from "China Ocean Shipping Company(COSCO)".
The third input consists of an integer that corresponds to the quotation from "Evergreen Marine".
Output Format:
The output consists of String which corresponds to the shipping
company name which is selected for shipping.
If more than one quotes are equal select the company based on the
priority (Input entered order). Refer sample input and output.
[All text in bold corresponds to input and rest corresponds to output.]
Sample Input and Output 1:
65
89
56
Evergreen Marine
Sample Input and Output 2:
55
55
78
Mediterranean Shipping Company
Full working JAVA code:
import java.io.*;
import java.util.Scanner;
class Demo {
public static void main (String[] args) {
//Create object of scanner class to take user
input
Scanner sc = new Scanner(System.in);
//Take 3 integer inputs from user
int input1 = sc.nextInt();
int input2 = sc.nextInt();
int input3 = sc.nextInt();
//Define variable min with input1 value
int min = input1;
//If input2 has smaller value than min, then update
the min value
if(input2 < min)
min = input2;
//Same with input3
if(input3 < min)
min = input3;
//By now we got the minimum value of the three in
varible "min"
//Check if first value is only the minimum value and
print the answer
if(input1 == min)
System.out.println("Mediterranean Shipping
Company");
//Check if second input has the lowest value
else if(input2 == min)
System.out.println("China Ocean Shipping
Company(COSCO)");
//If nothing works then input3 is the answer
else
System.out.println("Evergreen Marine");
}
}
Input:
55
95
55
Output:
Mediterranean Shipping Company