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: