Advertisement
Guest User

Untitled

a guest
Oct 19th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Grades
  4. {
  5. public static void main(String[] args)
  6. {
  7. Scanner keyboard = new Scanner (System.in);
  8. System.out.println("Please provide the numeric value of your overall grade in a class: ");
  9. int n = keyboard.nextInt();
  10. if(n >= 90)
  11. {
  12. System.out.println("A");
  13. }
  14.  
  15. if(n >= 80 && n <=89)
  16. {
  17. System.out.println("B");
  18. }
  19.  
  20. if(n >= 70 && n <= 79)
  21. {
  22. System.out.println("C");
  23. }
  24.  
  25. if(n >= 60 && n <= 69)
  26. {
  27. System.out.println("D");
  28. }
  29.  
  30. if(n >= 0 && n <= 59)
  31. {
  32. System.out.println("F");
  33. }
  34. }
  35. }
  36.  
  37.  
  38. import java.util.Scanner;
  39.  
  40. public class IPaddress {
  41.  
  42. public static void main(String[] args) {
  43. Scanner s = new Scanner(System.in);
  44. System.out.println("Please enter the first octet:");
  45. int input1 = s.nextInt();
  46. System.out.println("Please enter the second octet:");
  47. int input2 = s.nextInt();
  48. System.out.println("Please enter the third octet:");
  49. int input3 = s.nextInt();
  50. System.out.println("Please enter the fourth octet:");
  51. int input4 = s.nextInt();
  52. boolean valid = true;
  53. if (input1 < 0 || input1 > 255) {
  54. System.out.println("Octet 1 is incorrect");
  55. valid = false;
  56. }
  57. if (input2 < 0 || input2 > 255) {
  58. System.out.println("Octet 2 is incorrect");
  59. valid = false;
  60. }
  61. if (input3 < 0 || input3 > 255) {
  62. System.out.println("Octet 3 is incorrect");
  63. valid = false;
  64. }
  65. if (input4 < 0 || input4 > 255) {
  66. System.out.println("Octet 4 is incorrect");
  67. valid = false;
  68. }
  69. if (valid) {
  70. System.out.println("IP Address: "
  71. + input1 + "." + input2 + "." + input3 + "." + input4);
  72. }
  73. }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement