Java MP
Java MP
Java MP
SYCO
SEMESTER 4[2021-2022]
Rahul Gagdale
Kirtan Shimpi
Kalpesh Borse
Jayesh Mhanjan
Lalit Borse
Seal of
Institution
ACKNOWLEDGEMENT
We would like to express our special thanks of gratitude to our
institute Goverement Polytechnic Nandurbar our subject teacher
MR. Magan Vasave who gives us opportunity to make this micro
project on the topic "To Write a Program in java to define class
Flight_Management that calculate the value of fuel In flight”. This
has greatly helped us in expanding my cohere of knowledge. We are
thankful to each other because every one of us aided to complete
this project within the limited frame of time.
PROPOSAL
PROPOSAL
1.0 Aim/Benfits of the Micro-Project:
Aim:- To Write a Program in java to define class Flight_Management that calculate the value
of fuel In flight.
Benefits:-
The Project aims at the better development development and understanding the basics of JAVA
programming. It gives us through knowledge of classes and object avaible in JAVA.We know
how to to Implement If …Else If in JAVA.
1. Action Plan:
Name Of
Responsible
Sr No Activity Details Starting Date Finishing Date
Team
Members
Getting the overview 5/03/2022 Kalpesh Borse
1. of the project
2. Resources Used
Sr. No Name of
Specification Quantity
Resource/material
1. Computer System Intel i5 6600k, 8GB Ram 1
2. Software 1 Window 10 1
3. Software 2 Jdk-15.0.2 1
(Subject Teacher)
Mr. Magan Vasave
Report
1.0 Rationale
Java is platform independent, open-source object oriented programming language enriched
with free and open source libraries. In current industrial screnario Java has the broad industry
support and is prerequisite with many allied technologies like Advanced Java, Java Server
Pages and Android Application Development. Thus current industrial trends necessitate
acquiring Java knowledge for Computer Engineering graduates. This course develops
necessary skills in students to apply object oriented programming techniques in Java so that
students will be able to develop complete applications using core Java.
Class
A class is a user defined blueprint or prototype from which objects are created. It represents
the set of properties or methods that are common to all objects of one type. In general, class
declarations can include these components, in order:
1. Modifiers: A class can be public or has default access (Refer this for details).
2. class keyword: class keyword is used to create a class.
3. Class name: The name should begin with an initial letter (capitalized by convention).
4. Superclass(if any): The name of the class’s parent (superclass), if any, preceded by the
keyword extends. A class can only extend (subclass) one parent.
5. Interfaces(if any): A comma-separated list of interfaces implemented by the class, if any,
preceded by the keyword implements. A class can implement more than one interface.
6. Body: The class body surrounded by braces, { }.
Syntax:
Class classname
{
Variable declaration:
Method declaration;
}
Constructor
When discussing about classes, one of the most important sub topic would be constructors.
Every class has a constructor. If we do not explicitly write a constructor for a class, the Java
compiler builds a default constructor for that class.
Each time a new object is created, at least one constructor will be invoked. The main rule of
constructors is that they should have the same name as the class. A class can have more than
one constructor.
Scanner Classes
Scanner class in Java is found in the java.util package. Java provides various ways to read
input from the keyboard, the java.util.Scanner class is one of them.
The Java Scanner class breaks the input into tokens using a delimiter which is whitespace by
default. It provides many methods to read and parse various primitive values.
The Java Scanner class is widely used to parse text for strings and primitive types using a
regular expression. It is the simplest way to get input in Java. By the help of Scanner in Java,
we can get input from the user in primitive types such as int, long, double, byte, float, short,
etc.
The Java Scanner class extends Object class and implements Iterator and Closeable interfaces.
The Java Scanner class provides nextXXX() methods to return the type of value such as
nextInt(), nextByte(), nextShort(), next(), nextLine(), nextDouble(), nextFloat(),
nextBoolean(), etc. To get a single character from the scanner, you can call next().charAt(0)
method which returns a single character.
Syntax:
If-else-If Staement
The if-else-if ladder statement executes one condition from multiple statements.
Syntax:
if(condition1){
//code to be executed if condition1 is true
}
else if(condition2){
//code to be executed if condition2 is true
} else
if(condition3){
//code to be executed if condition3 is true
}
...
else{
//code to be executed if all the conditions are false
}
Java.util.Scanner
The java.util.Scanner class is a simple text scanner which can parse primitive types and strings
using regular expressions.Following are the important points about Scanner − A Scanner
breaks its input into tokens using a delimiter pattern, which by default matches whitespace.
• A scanning operation may block waiting for input.
• A Scanner is not safe for multithreaded use without external synchronization
3. Software 2 Jdk-15.0.2 1
import java.util.Scanner;
public class Flight_Management_P
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
System.out.print("Enter the Flight number:");
int num = in.nextInt(); System.out.print("Enter
the Orgin:");
String origin = in.next();
System.out.print("Enter the Destination:");
String destination = in.next();
System.out.print("Enter the Distance:"); long
distance = in.nextLong();
System.out.println("*************************");
System.out.println("Flight Number is:"+num);
System.out.println("Origin of Flight:"+origin);
System.out.println("Destination of Flight:"+destination);
System.out.println("Distance of Flight:"+distance); if(distance<=1000)
{
System.out.println("Value of Fuel = 500");
}
else if(distance>1000 && distance<=2000)
{
System.out.println("Value of Fuel = 1100");
}
else if(distance>2000)
{
System.out.println("Value of Fuel = 2200");
}
System.out.println("*************************");
}
}
OUTPUT :-
Subject Teacher