Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Grades
- {
- public static void main(String[] args)
- {
- Scanner keyboard = new Scanner (System.in);
- System.out.println("Please provide the numeric value of your overall grade in a class: ");
- int n = keyboard.nextInt();
- if(n >= 90)
- {
- System.out.println("A");
- }
- if(n >= 80 && n <=89)
- {
- System.out.println("B");
- }
- if(n >= 70 && n <= 79)
- {
- System.out.println("C");
- }
- if(n >= 60 && n <= 69)
- {
- System.out.println("D");
- }
- if(n >= 0 && n <= 59)
- {
- System.out.println("F");
- }
- }
- }
- import java.util.Scanner;
- public class IPaddress {
- public static void main(String[] args) {
- Scanner s = new Scanner(System.in);
- System.out.println("Please enter the first octet:");
- int input1 = s.nextInt();
- System.out.println("Please enter the second octet:");
- int input2 = s.nextInt();
- System.out.println("Please enter the third octet:");
- int input3 = s.nextInt();
- System.out.println("Please enter the fourth octet:");
- int input4 = s.nextInt();
- boolean valid = true;
- if (input1 < 0 || input1 > 255) {
- System.out.println("Octet 1 is incorrect");
- valid = false;
- }
- if (input2 < 0 || input2 > 255) {
- System.out.println("Octet 2 is incorrect");
- valid = false;
- }
- if (input3 < 0 || input3 > 255) {
- System.out.println("Octet 3 is incorrect");
- valid = false;
- }
- if (input4 < 0 || input4 > 255) {
- System.out.println("Octet 4 is incorrect");
- valid = false;
- }
- if (valid) {
- System.out.println("IP Address: "
- + input1 + "." + input2 + "." + input3 + "." + input4);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement