Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package jtvi2023b8;
- public class Day06A {
- public static void main(String[] args) {
- int grade = 60;
- String result = "invalid";
- // nested if version
- if (grade <= 100) {
- if (grade >= 97) {
- result = "1.0";
- }
- }
- if (grade <= 96 && grade >= 94) {
- result = "1.25";
- } else if (grade <= 93 && grade >= 91) {
- result = "1.50";
- } else if (grade <= 90 && grade >= 88) {
- result = "1.75";
- } else if (grade <= 87 && grade >= 85) {
- result = "2.0";
- } else if (grade <= 84 && grade >= 82) {
- result = "2.25";
- } else if (grade <= 81 && grade >= 79) {
- result = "2.50";
- } else if (grade <= 78 && grade >= 76) {
- result = "2.75";
- } else if (grade == 75) {
- result = "3.0";
- } else if (grade < 75) {
- result = "Failed";
- }
- System.out.println(grade + " have a score of " + result);
- }
- }
- //-------------------------------------------
- package jtvi2023b8;
- public class Day06B {
- public static void main(String[] args) {
- double num1 = 32, num2 = 21, result = 0;
- String op = "-";
- if (op == "+") {
- result = num1 + num2;
- } else if (op == "-") {
- result = num1 - num2;
- } else if (op == "*") {
- result = num1 * num2;
- }
- System.out.println(num1 + op + num2 +" = " + result);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment