0% found this document useful (0 votes)
9 views7 pages

PFA1

The document contains two Java programs: the first is a UCP Grade Calculator that determines a student's grade based on attendance and marks, while the second is a Burger Order System that allows users to select a burger, side, and drink, and calculates the total cost of the order. Both programs utilize user input and conditional statements to provide feedback and results. They demonstrate basic programming concepts such as loops, conditionals, and input handling.
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)
9 views7 pages

PFA1

The document contains two Java programs: the first is a UCP Grade Calculator that determines a student's grade based on attendance and marks, while the second is a Burger Order System that allows users to select a burger, side, and drink, and calculates the total cost of the order. Both programs utilize user input and conditional statements to provide feedback and results. They demonstrate basic programming concepts such as loops, conditionals, and input handling.
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
You are on page 1/ 7

Question No:1

Ucp grade calculater


import java.util.Scanner;

public class UCPGradeCalculator {

public static void main(String[] args) {

Scanner input = new Scanner(System.in);

System.out.print("enter number of absents: ");

int abs = input.nextInt();

if (abs > 12) {

System.out.println("You failed due to low attendance. Grade: FA");

} else {

System.out.println("\nSelect Course Type:");

System.out.println("1. Single Component Course");

System.out.println("2. Dual Component Course");

System.out.print("Enter your choice (1 or 2): ");

int ch = input.nextInt();

if (ch == 1) {

System.out.print("Enter your marks (out of 100): ");

int marks = input.nextInt();

String grade = getGrade(marks);

System.out.println("Your Grade is: " + grade);

else if (ch == 2) {

System.out.print("Enter Theory marks (out of 100): ");

int thMarks = input.nextInt();

System.out.print("Enter Lab marks (out of 100): ");

int labMarks = input.nextInt();

if (thMarks < 60) {


System.out.println("You failed the Theory part. Grade: F");

System.out.println("You also failed the Lab part due to failing theory. Grade: F");

} else {

String thGrade = getGrade(thMarks);

String labGrade = getGrade(labMarks);

System.out.println("Your Theory Grade is: " + thGrade);

System.out.println("Your Lab Grade is: " + labGrade);

else {

System.out.println("Invalid choice. Please run the program again.");

input.close();

public static String getGrade(int marks) {

if (marks >= 90) {

return "A";

} else if (marks >= 80) {

return "B";

} else if (marks >= 70) {

return "C";

} else if (marks >= 60) {

return "D";

} else {

return "F";

}
}

QUESTION 2:
Burger order system:
import java.util.Scanner;
public class BurgerOrder {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String bName = "", sName = "", dName = "";
int bPrice = 0, sPrice = 0, dPrice = 0;
System.out.println(" Please place your order.");
System.out.println("Select a Burger:");
System.out.println("1. Zinger Burger - Rs. 450");
System.out.println("2. Beef Burger - Rs. 500");
System.out.println("3. Chicken Burger - Rs. 400");
System.out.println("4. Exit");
System.out.print("Enter choice: ");
int b = sc.nextInt();
if (b == 4) {
System.out.println("Thank you. Visit again!");
return;
} else if (b == 1) {
bName = "Zinger Burger";
bPrice = 450;
} else if (b == 2) {
bName = "Beef Burger";
bPrice = 500;
} else if (b == 3) {
bName = "Chicken Burger";
bPrice = 400;
} else {
System.out.println("Invalid burger choice. Try again.");
return;
}
System.out.println("Select a Side:");
System.out.println("1. Fries - Rs. 150");
System.out.println("2. Nuggets - Rs. 200");
System.out.println("3. No Side - Rs. 0");
System.out.print("Enter choice: ");
int s = sc.nextInt();
if (s == 1) {
sName = "Fries";
sPrice = 150;
} else if (s == 2) {
sName = "Nuggets";
sPrice = 200;
} else if (s == 3) {
sName = "No Side";
sPrice = 0;
} else {
System.out.println("Invalid side choice. Try again.");
return;
}
System.out.println("Select a Drink:");
System.out.println("1. Coke - Rs. 100");
System.out.println("2. Sprite - Rs. 100");
System.out.println("3. No Drink - Rs. 0");
System.out.print("Enter choice: ");
int d = sc.nextInt();
if (d == 1) {
dName = "Coke";
dPrice = 100;
} else if (d == 2) {
dName = "Sprite";
dPrice = 100;
} else if (d == 3) {
dName = "No Drink";
dPrice = 0;
} else {
System.out.println("Invalid drink choice. Try again.");
return;
}

System.out.print("Do you want to proceed with your order? (Y/N): ");


char ch = sc.next().charAt(0);
if (ch == 'Y' || ch == 'y') {
int total = bPrice + sPrice + dPrice;
System.out.println("Your Order,s Summary:");
System.out.println("Burger: " + bName);
System.out.println("Side: " + sName);
System.out.println("Drink: " + dName);
System.out.println("Total: " + total);
System.out.println("Thank you for visiting Burger Have a great day!");
} else {
System.out.println("Order cancelled. Thank you!");
}

sc.close();
}
}

You might also like