Question

Hey, Im trying to understand what this code is telling me. Plus what do I need...

Hey, Im trying to understand what this code is telling me. Plus what do I need to add to run it? Im new with coding, really trying to understand everything. Thanks

String name = console.next();

if (name.startsWith("Dr.")) {

System.out.println("Are you single?");

}

else if (name.equalsIgnoreCase("LUMBERG")) {

System.out.println("I need your TPS reports."); }

0 0
Add a comment Improve this question Transcribed image text
Answer #1
import java.util.Scanner;

public class TPSReports {

    public static void main(String[] args) {
        Scanner console = new Scanner(System.in);

        String name = console.nextLine();   // read name from user

        if (name.startsWith("Dr.")) {   // if name starts with Dr.
            System.out.println("Are you single?");  // then print Are you single? 
        } else if (name.equalsIgnoreCase("LUMBERG")) { // if name is LUMBERG 
            System.out.println("I need your TPS reports."); // then print I need your TPS reports. 
        }
    }

}

Add a comment
Know the answer?
Add Answer to:
Hey, Im trying to understand what this code is telling me. Plus what do I need...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Can someone explain me parts of this code I do not fully understand what its doing...

    Can someone explain me parts of this code I do not fully understand what its doing or what its purpose is. I have highlighted the parts I'm confused over. Please explain thoroughly. import java.util.Scanner; class A1Stats { public static void main(String args[]) { double min, max, sum, mean; int n; Scanner scanner = new Scanner(System.in); String input = scanner.nextLine(); String[] numbers = input.split(" "); double value[] = new double[numbers.length]; if(numbers.length > 0){ for (int i = 0; i < numbers.length;...

  • I am trying to understand how to manipulate the Gregorian Calendar so that I can convert...

    I am trying to understand how to manipulate the Gregorian Calendar so that I can convert my answer into a string format. What I'm hoping to do is to do is return string to a different file to add to a string in separate file (Object-oriented exercise between files), but once I can convert this into a string I can convert this file on my own. I added the System.out.println() to show what the results should look like. In other...

  • I am trying to understand the following code I found in a website so that I...

    I am trying to understand the following code I found in a website so that I can use it for a project that evaluates boolean expressions. The code is below but I think it is in java because I do not understand it. Can you help me describe what it is doing in c++ so that I can understand it better? The link to the code is here: https://stackoverflow.com/questions/16762057/algorithm-to-evaluate-value-of-boolean-expression The code is below: public static boolean evaluateBool(String s) { Stack<Object>...

  • Saw this code online an im trying to understand each step. Can someone add comments to...

    Saw this code online an im trying to understand each step. Can someone add comments to this ? package javaapplication5; interface PairInterface<String>{ void setFirst(String first); void setSecond(String second); String getFirst(); String getSecond();    } class BasicPair<String> implements PairInterface{ String first; String second; BasicPair(String first,String second){ this.first=first; this.second=second; } @Override public String getFirst() { return first; } @Override public String getSecond() { return second; } @Override public void setFirst(Object first ) { this.first=(String)first; } @Override public void setSecond(Object second) { this.second=(String)second;...

  • Java Branches code not working please HELP!! I am trying to build this class that will...

    Java Branches code not working please HELP!! I am trying to build this class that will ask for an ingredient, and the number of cups of the ingredient. It should then branch into an if/else branch off to verify that the number entered is valid and that it is within range. Once that branch completes it should then continue on to ask for the calories per cup, and then calculate total calories. Once I get it to enter the branch...

  • Trying to figure out these methods for comp sci class and I really don't understand. Any...

    Trying to figure out these methods for comp sci class and I really don't understand. Any help would be really appreciated.       /**    *    */    public static int [] setNums(String vals)    {    //this is a helper method to convert a string to an array for searching purposes        //declare and instantiate an array with length as the number of chars in vals               //lopp through each char in vals   ...

  • I do not understand what the GDP is telling me as of July 30. What is...

    I do not understand what the GDP is telling me as of July 30. What is happening? Can you interpret in detail why GDP is down as of July 30? Can you explain what this chart is telling us? I'll really appreciate it! QUOTES & COMPANIES Goodrich Petroleum Corp. GDP (U.S.: NYSE American) VIEW ALL COMPANIES 1D 5D 1M 3M AT CLOSE 4:00 PM EDT 07/30/20 YTD 17 3 Y Volume 18,796 $6.93 USD -0.16 -2.26% 65 Day Avg Vol...

  • hey dear i just need help with update my code i have the hangman program i...

    hey dear i just need help with update my code i have the hangman program i just want to draw the body of hang man when the player lose every attempt program is going to draw the body of hang man until the player lose all his/her all attempts and hangman be hanged and show in the display you can write the program in java language: this is the code bellow: import java.util.Random; import java.util.Scanner; public class Hangmann { //...

  • Can someone help me with my code.. I cant get an output. It says I do...

    Can someone help me with my code.. I cant get an output. It says I do not have a main method. HELP PLEASE. The instruction are in bold on the bottom of the code. package SteppingStones; //Denisse.Carbo import java.util.Scanner; import java.util.ArrayList; import java.util.List; public class SteppingStone5_Recipe { private String recipeName; private int servings; private List<String> recipeIngredients; private double totalRecipeCalories; public String getRecipeName() { return recipeName; } public void setRecipeName (string recipeName){ this.recipeName = recipeName; } public int getServings() { return...

  • Can you help me rearrange my code by incorporating switch I'm not really sure how to...

    Can you help me rearrange my code by incorporating switch I'm not really sure how to do it and it makes the code look cleaner. Can you help me do it but still give the same output? Also kindly add an in-line comment on what changes and rearrangement you've done so I can understand what's going on. import java.util.ArrayList; import java.util.Scanner; public class Bank { /** * Add and read bank information to the user. * @param arg A string,...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT