Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class ProblemSet02 {
- public static void main(String[] args) {
- /*type name of problemset task after comment.*/bePositive();
- //right here ^
- // |
- /*options include:
- – Road Rage (roadRage)
- – Password Please (passwordPlease)
- – Egg Head (eggHead)
- – Be Positive (bePositive)
- – Good Grades (goodGrades)
- – Optimus Prime (optimusPrime)
- – ID And Password Please (idAndPasswordPlease)
- – RichIQ (richIQ)
- */
- }
- public static void roadRage(){
- Scanner sc = new Scanner(System.in);
- System.out.println("What is your age?");
- int age = sc.nextInt();
- if (age >= 16){
- System.out.println("Congrats! You are old enough to drive!");
- }
- else {
- System.out.println("Sorry! You are not old enough to drive!");
- }
- }
- public static void passwordPlease(){
- Scanner sc = new Scanner(System.in);
- System.out.println("Enter your password.");
- String password = sc.nextLine();
- if (password.equals("Apcs2018")){
- System.out.println("Good Password!");
- }
- else {
- System.out.println("Password Incorrect!");
- }
- }
- public static void eggHead(){
- Scanner sc = new Scanner(System.in);
- System.out.println("How many eggs would you like to buy?");
- int eggAmount = sc.nextInt();
- if (eggAmount >= 100){
- double eggPrice = 0.2;
- double eggTotal = eggPrice*eggAmount;
- System.out.println("Your total is $"+eggTotal+".");
- }
- else {
- double eggPrice = 0.25;
- double eggTotal = eggPrice*eggAmount;
- System.out.println("Your total is $"+eggTotal+".");
- }
- }
- public static void bePositive(){
- Scanner sc = new Scanner(System.in);
- System.out.println("Enter an integer.");
- int integer = sc.nextInt();
- determineInteger(integer);
- if (positivity == 1){
- System.out.println("The integer "+integer+" is negative.");
- }
- else if (positivity ==2){
- System.out.println("The integer "+integer+" is positive.");
- }
- else {
- System.out.println("The integer "+integer+" is zero!");
- }
- }
- public static int determineInteger(int integer){
- if (integer < 0){
- positivity = 1;
- }
- else if (integer >0){
- positivity = 2;
- }
- else {
- positivity = 3;
- }
- return int
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement