Java Program to Calculate Cubic Capacity in Bikes

Java program to calculate cubic capacity cc in bikes. The cubic capacity of a motorcycle’s engine is the unit of measurement. Vehicle cubic capacity, generally known as “cc,” typically ranges from 50cc to 1500cc. The larger the chamber of a two-wheeler, the more powerful it is thought to be. The capacity of a bike is calculated in the same manner as the engine capacity of a four-wheeler vehicle is measured in litres.

import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int cc = sc.nextInt();

if(100>cc){
System.out.println("Enter the large number");
}
if(100<=cc && 125>=cc){
System.out.println(75);
}
if(126<=cc && 135>=cc){
System.out.println(70);
}
if(136<=cc && 150>=cc){
System.out.println(60);
}
if(151<=cc && 200>=cc){
System.out.println(50);
}
if(201<=cc && 220>=cc){
System.out.println(35);
}
if(cc>220){
System.out.println("The number is very large");
}
}
}

 

Output

220
35

If Else Statement in Java Program

In Java, the if statement is used to execute a block of code if a condition is true. If a condition evaluates to false, the if…else statement is used alongside an if statement to run code. The if…else…if phrase is also used to test several conditions. The simplest basic decision-making statement in Java is the if statement. It is used to determine if a statement or a block of statements will be executed or not, that is, if a condition is true, a block of statements will be performed; otherwise, it will not.

sc.NextInt() in Java

This scanner’s next() method locates and returns the next complete token. Input that matches the delimiter pattern comes before and after a complete token. Even if a previous invocation of has Next() returned true, this method may block while waiting for input to scan. Using this program we can execute the Java program to calculate cubic capacity cc in bikes