Question

In: Computer Science

1- Create a Java program to determine a certain number whether that number is odd or...

1- Create a Java program to determine a certain number whether that number is odd or even.
Hint : use arithmetic operators and expressions to find the odd or even numbers.

2- Create a Java program to ask a user to enter a name and password as shown below:
name is “Ahmed” and his password is 2321 or name is “Ali” and his password is 6776 . The program shows a greeting “Hi ..Welcome to my program” if the user is “Ahmed” Or “Ali” otherwise it will shows a message “Sorry!! I don’t recognize you”.
Hint : use conditional and Boolean Operators.

3- Create a Java problem to ask a user to enter a GPA grade and based on that grade it will determine if the user is one of the Honor list or not.
Hint :   
- GPA is more than or equal 3.90 shows message “Excellent .. you are at First honor”
- GPA is more than or equal 3.70 shows message “Excellent .. you are at Second honor ”
- GPA is More than or equal 3.50 shows message “Excellent .. you are at Third honor” GPA is less than 3.50 and more than or equal 2.00 shows message “Good .. Work hard to raise your GPA”
- Otherwise shows message “WORK HARD … You are in trouble”

Solutions

Expert Solution

  • 1).
  • Code:-

import java.util.Scanner;
class Even_Odd{
public static void main(String[] args){
int num;
Scanner in = new Scanner(System.in);
System.out.print("Enter a number to check: ");
num = in.nextInt();
if(num % 2 == 0){
System.out.println("Even");
} else {
System.out.println("Odd");
}
}
}

  • Output:-

  • 2).
  • Code:-

import java.util.Scanner;
class User{
public static void main(String[] args){
int password;
String username;

Scanner in = new Scanner(System.in);
//get username from user
System.out.print("Enter your username: ");
username = in.next();
//get password from user
System.out.print("Enter your password: ");
password = in.nextInt();
//if username is Ahmed and password is 2321
if(username.equals("Ahmed") && password==2321){
System.out.println("Hi ..Welcome to my program");
}
//if username is Ali and password is 6776
else if(username.equals("Ali") && password==6776){
System.out.println("Hi ..Welcome to my program");
} //if username and password are not recognized
else {
System.out.println("Sorry!! I don’t recognize you");
}
in.close();
}
}

  • Output:-

  • 3).
  • Code:-

import java.util.Scanner;
class Gpa {
public static void main(String[] args){
float gpa;
Scanner in = new Scanner(System.in);

System.out.print("Enter gpa: ");
gpa = in.nextFloat();
// Gpa > 3.90
if(gpa >= 3.90){
System.out.println("Excellent .. you are at First honor");
} // Gpa > 3.70
else if(gpa >= 3.70){
System.out.println("Excellent .. you are at Second honor");
} // Gpa > 3.5
else if(gpa >= 3.50){
System.out.println("Excellent .. you are at Third honor");
} //Gpa < 3.50 and > 2.00
else if(gpa < 3.50 && gpa >= 2.00){
System.out.println("Good .. Work hard to raise your GPA");
} // Otherwise
else {
System.out.println("WORK HARD … You are in trouble");
}
in.close();
}
}

  • Output:-

Thank You...!


Related Solutions

Create an application that checks whether an integer is an odd or even number. Welcome to...
Create an application that checks whether an integer is an odd or even number. Welcome to the Odd/Even Checker! Enter an integer: ten Error! Invalid integer. Try again. Enter an integer: 10.3 Error! Invalid integer. Try again. Enter an integer: 10 The number 10 is even. Continue? (y/n): Error! This entry is required. Try again. Continue? (y/n): y Enter an integer: 9 The number 9 is odd. Continue? (y/n): n Specifications: Create a version of the Console class presented in...
Write a program to test whether a number provided from key board input is either odd...
Write a program to test whether a number provided from key board input is either odd or even. Don't forget the case that 0 is an even number. for C++ please
C++ Create a program that checks whether a number is a prime number and displays its...
C++ Create a program that checks whether a number is a prime number and displays its factors if it is not a prime number. Console Prime Number Checker Please enter an integer between 1 and 5000: 5 5 is a prime number. Try again? (y/n): y Please enter an integer between 1 and 5000: 6 6 is NOT a prime number. It has 4 factors: 1 2 3 6 Try again? (y/n): y Please enter an integer between 1 and...
java program Create a program that creates and prints a random phone number using the following...
java program Create a program that creates and prints a random phone number using the following format: XXX-XXX-XXXX. Make sure your output include the dashes.  Do not let the first three digits contain an 8 or 9 (HINT: do not be more restrictive than that) and make sure that the second set of three digits is not greater than 773. Helpful Hint:   Think though the easiest way to construct the phone number. Each digit does do not have to be determined...
Design an algorithm to prompt user to enter a number. Determine the number is odd or...
Design an algorithm to prompt user to enter a number. Determine the number is odd or even with Case Logic.
Java Programming Create a program that prompts the user for an integer number and searches for...
Java Programming Create a program that prompts the user for an integer number and searches for it within an array of 10 elements. What is the average number of comparisons required to find an element in the array? Your program should print the number of comparisons required to find the number or determine that the number does not exist. Try finding the first and last numbers stored in the array. Run your program several times before computing the average.
Write program numsODD that uses the method to create arrays of odd nums starting 1 of...
Write program numsODD that uses the method to create arrays of odd nums starting 1 of the given length: public static int[] getnumsOdd(int length) {} int[] numbers = getnumsOdd(5); System.out.println(Arrays.toString(numbers)); output: [1, 3, 5, 7, 9]
Write c code to determine if a binary number is even or odd. If it is...
Write c code to determine if a binary number is even or odd. If it is odd, it outputs 1, and if it is even, it outputs 0. It has to be less than 12 operations. The operations have to be logical, bitwise, and arithmetic.
Write a program in java which store 10 numbers and find the sum of odd and...
Write a program in java which store 10 numbers and find the sum of odd and even numbers. Create a program that uses a two dimensional array that can store integer values inside. (Just create an array with your own defined rows and columns). Make a method called Square, which gets each of the value inside the array and squares it. Make another method called ShowNumbers which shows the squared numbers. Write a program in java which has an array...
Write a program in java which store 10 numbers and find the sum of odd and...
Write a program in java which store 10 numbers and find the sum of odd and even numbers. Create a program that uses a two dimensional array that can store integer values inside. (Just create an array with your own defined rows and columns). Make a method called Square, which gets each of the value inside the array and squares it. Make another method called ShowNumbers which shows the squared numbers.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT