VASUNDARA Step Program
VASUNDARA Step Program
N (RA2412703010023)-NWC
1)Write a program to find the age of Harry if the birth year is 2000. Assume
the Current Year is 2024
import java.util.Scanner;
scanner.close();
}
Input:
2) Sam’s mark in Maths is 94, Physics is 95 and Chemistry is 96 out of 100. Find the average
percent mark in PCM
import java.util.Scanner;
int totalSubjects = 3;
int maxMarksPerSubject = 100;
scanner.close();
Input:
import java.util.Scanner;
scanner.close();
}
}
Input:
4) Create a program to calculate the profit and loss in number and percentage based on the
cost price of INR 129 and the selling price of INR 191.
import java.util.Scanner;
(profitOrLoss > 0 ?
);
scanner.close();
}
}
Input:
1. 5) Suppose you have to divide 14 pens among 3 students equally. Write a program
to find how many pens each student will get if the pens must be divided equally.
Also, find the remaining non-distributed pens.
import java.util.Scanner;
public class PenDistribution {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter the total number of pens: ");
int totalPens = scanner.nextInt();
System.out.print("Enter the number of students: ");
int students = scanner.nextInt();
int pensPerStudent = totalPens / students;
System.out.println(
"\nTotal Pens: " + totalPens +
"\nTotal Students: " + students +
"\nEach student gets: " + pensPerStudent + " pens" +
"\nRemaining non-distributed pens: " + remainingPens
);
scanner.close();
}
}
Input:
Output: The Pen Per Student is and the remaining pen not distributed is
1. 6) The University is charging the student a fee of INR 125000 for the course. The University
is willing to offer a discount of 10%. Write a program to find the discounted amount and
discounted price the student will pay for the course.
import java.util.Scanner;
System.out.println(
);
scanner.close();
Input:
Output: The discount amount is INR and final discounted fee is INR
import java.util.Scanner;
System.out.println(
);
scanner.close();
}
}
Input:
import java.util.Scanner;
double km = input.nextDouble();
input.close();
}
}
Input:km
1. 9) Write a new program similar to the program # 6 but take user input for Student Fee and
University Discount
import java.util.Scanner;
System.out.println(
);
scanner.close();
}
}
Output: The discount amount is INR and final discounted fee is INR
10) Write a program that takes your height in centimeters and converts it into feet and inches
import java.util.Scanner;
System.out.println("\nYour height is: " + feet + " feet " + inches + " inches.");
scanner.close();
}
}
Input: height