0% found this document useful (0 votes)
3 views11 pages

Java Level 1

The document contains ten Java programs that perform various calculations, including age calculation, distance conversion from kilometers to miles, profit and loss calculations, division of pens among students, discount calculations, and volume of Earth in cubic kilometers and miles. It also includes programs that take user input for distance and fees, converting British height measurements to American units, and calculating average marks in subjects. Each program is designed to demonstrate basic programming concepts and arithmetic operations.

Uploaded by

vik737610
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views11 pages

Java Level 1

The document contains ten Java programs that perform various calculations, including age calculation, distance conversion from kilometers to miles, profit and loss calculations, division of pens among students, discount calculations, and volume of Earth in cubic kilometers and miles. It also includes programs that take user input for distance and fees, converting British height measurements to American units, and calculating average marks in subjects. Each program is designed to demonstrate basic programming concepts and arithmetic operations.

Uploaded by

vik737610
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Level-1 Programs:

Program-1:
class Age{
public static void main(String[] args){
int born_year=2000;
[Link]("Age is: "+(2024-
born_year));
}
}
Output:

Program2-:
class Tomiles{
public static void main(String[] args){
double km=10.8;
[Link]("The distance "+km+"
km in miles is "+(km/1.6));
}
}

Output:

Program-3:
class Profitloss {
public static void main(String[] args) {
int CP = 129;
int SP = 191;

[Link]("The cost price is: ₹" + CP +


" and selling price is: ₹" + SP +
" The profit is: ₹" + (SP - CP) +
" The profit percentage is: " +
(((double)(SP - CP) / CP) * 100) + "%");
}
}

Output:

Program-4:
class Division {
public static void main(String[] args) {
int pens=14;
int students=3;
[Link]("The pen student is :"+
(pens/students)+" and remaining pen not
distributed is: "+(pens%students));
}
}

Output:

Program-5:
class Discount {
public static void main(String[] args) {
int fees=125000;
double discount=0.1;
[Link]("The discount amount is
INR: "+(fees*discount)+" and final discounted fee is
INR: "+(fees-(fees*discount)));
}
}
Output:

Program-6:
class Volume {
public static void main(String[] args) {
int radius = 6378;
double volumeKm3 = (4.0 / 3) * 3.14 *
radius * radius * radius;
double radiusMiles = radius / 1.6;
double volumeMiles3 = (4.0 / 3) * 3.14 *
radiusMiles * radiusMiles * radiusMiles;
[Link]("The volume of Earth in
cubic kilometers is: " + volumeKm3 +" and in cubic
miles is: " + volumeMiles3);
}
}

Output:

Program-7:
import [Link];
class Input_tomiles{
public static void main(String[] args){
Scanner sc=new Scanner([Link]);
[Link]("Enter the Km:");
double km=[Link]();
[Link]("The distance "+km+"
km in miles is "+(km/1.6));
}
}
Output:

Program-8:
import [Link];
class Input_discount {
public static void main(String[] args) {
Scanner sc=new Scanner([Link]);
[Link]("Enter the fees:");
int fees=[Link]();
[Link]("Enter the discount in
%:");
double discount=[Link]();
[Link]("The discount amount is
INR: "+(fees*discount*0.01)+" and final discounted
fee is INR: "+(fees-(fees*discount*0.01)));
}
}

Output:

Program-9:
import [Link];
class British_to_american{
public static void main(String[] args){
Scanner sc=new Scanner([Link]);
[Link]("Enter height in cm: ");
int height=[Link]();
[Link]("Your Height in cm
is :"+height+" while in feet is:
"+((double)(height/(12*2.54)))+" and inches is: "+
((double)(height/12)));
}
}
Output:

Program-10:

public class SamsAverage {


public static void main(String[] args) {
// Define the marks for Maths, Physics, and
Chemistry
int mathsMark = 94;
int physicsMark = 95;
int chemistryMark = 96;
// Define the total marks per subject
int totalMarksPerSubject = 100;
// Calculate the total marks obtained
int totalMarksObtained = mathsMark + physicsMark
+ chemistryMark;
// Calculate the average percentage
double averagePercent = (totalMarksObtained /
3.0); // Divide by 3 for average
// Print the result
[Link]("Sam's average percentage in
PCM is: " + averagePercent + "%");
}
}

Output:

You might also like