Question

Create a simple server application that accepts the name of a state and provides the client...

Create a simple server application that accepts the name of a state and provides the client with the cost for travel. Use the table below to provide the three scenarios. Trip to Arizona - $500 Trip to New York - $600 Trip to Utah - $300 Create a client application that provides the user with the airfare cost per their state selection. See the table above. For example, if the user enters Arizona, the client should respond with the cost of $500.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

SOURCE CODE ;

Server Class


public class Server {
private String state;
private double travleCost;
public Server(String state) {
this.state = state;
this.travleCost = calculateTravleCost();
}
private double calculateTravleCost() {
if (state.equalsIgnoreCase("Arizona")) {
return 500;
} else if (state.equalsIgnoreCase("New York")) {
return 600;
} else if (state.equalsIgnoreCase("Utah")) {
return 300;
} else {
return 0;
}
}
public String getState() {
return state;
}
public double getTravleCost() {
return travleCost;
}
}


Client Class

import java.util.Scanner;
public class Client {
public static void main(String[] args) {
Scanner userInput = new Scanner(System.in);
System.out.print("Please enter state name: ");
String state = userInput.nextLine();
Server server = new Server(state);
double travelCost = server.getTravleCost();
System.out.println("Airfare Cost for Trip to "+state+" is $"+travelCost);
userInput.close();
}
}

Add a comment
Know the answer?
Add Answer to:
Create a simple server application that accepts the name of a state and provides the client...
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
  • Create a simple server application that accepts the name of a state and provides the client...

    Create a simple server application that accepts the name of a state and provides the client with the cost for travel. Use the table below to provide the three scenarios. Trip to Arizona - $500 Trip to New York - $600 Trip to Utah - $300 Create a client application that provides the user with the airfare cost per their state selection. See the table above. For example, if the user enters Arizona, the client should respond with the cost...

  • A test specification provides designers with what needs to be known in order to perform a...

    A test specification provides designers with what needs to be known in order to perform a specific test, and to validate and verify the requirement to be tested. The test script is divided into the test script, which is the generic condition to be tested, and one or more test cases within the test script. Provide a test script and test case for at least 3 of your requirements identified in your requirements specification. Provide the following format for an...

  • PL/SQL Auction Program 1. Create a user xyz, who is the owner of the auction. Create...

    PL/SQL Auction Program 1. Create a user xyz, who is the owner of the auction. Create the schema, and package. 2. Create users x1 and x2 who are the participants in the auction. They will need acces to the package. 3. Bid on the same item and record your observations. Verify all scenarios. Upload the files with the missing code and a detailed sample run. AUCTION OWNER.TXT SQL> conn / as sysdba Connected. SQL> drop user xyz cascade; User dropped....

  • 1. Many companies use a incoming shipments of parts, raw materials, and so on. In the...

    1. Many companies use a incoming shipments of parts, raw materials, and so on. In the electronics industry, component parts are commonly shipped from suppliers in large lots. Inspection of a sample of n components can be viewed as the n trials of a binomial experimem. The outcome for each component tested (trialD will be that the component is classified as good or defective defective components in the lot do not exceed 1 %. Suppose a random sample of fiver...

  • Risk management in Information Security today Everyday information security professionals are bombarded with marketing messages around...

    Risk management in Information Security today Everyday information security professionals are bombarded with marketing messages around risk and threat management, fostering an environment in which objectives seem clear: manage risk, manage threat, stop attacks, identify attackers. These objectives aren't wrong, but they are fundamentally misleading.In this session we'll examine the state of the information security industry in order to understand how the current climate fails to address the true needs of the business. We'll use those lessons as a foundation...

  • Please read the article and answer about questions. You and the Law Business and law are...

    Please read the article and answer about questions. You and the Law Business and law are inseparable. For B-Money, the two predictably merged when he was negotiat- ing a deal for his tracks. At other times, the merger is unpredictable, like when your business faces an unexpected auto accident, product recall, or government regulation change. In either type of situation, when business owners know the law, they can better protect themselves and sometimes even avoid the problems completely. This chapter...

  • Discussion questions 1. What is the link between internal marketing and service quality in the ai...

    Discussion questions 1. What is the link between internal marketing and service quality in the airline industry? 2. What internal marketing programmes could British Airways put into place to avoid further internal unrest? What potential is there to extend auch programmes to external partners? 3. What challenges may BA face in implementing an internal marketing programme to deliver value to its customers? (1981)ǐn the context ofbank marketing ths theme has bon pururd by other, nashri oriented towards the identification of...

  • First, read the article on "The Delphi Method for Graduate Research." ------ Article is posted below...

    First, read the article on "The Delphi Method for Graduate Research." ------ Article is posted below Include each of the following in your answer (if applicable – explain in a paragraph) Research problem: what do you want to solve using Delphi? Sample: who will participate and why? (answer in 5 -10 sentences) Round one questionnaire: include 5 hypothetical questions you would like to ask Discuss: what are possible outcomes of the findings from your study? Hint: this is the conclusion....

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