Question

In: Computer Science

BEFORE YOU START: Before working on this assignment you should have completed Assignment 1. PROGRAM STATEMENT...

BEFORE YOU START: Before working on this assignment you should have completed Assignment 1. PROGRAM STATEMENT AND REQUIREMENTS:

You will implement in Java the WIFI troubleshooting program you created in Assignment 1 with the following additional conditions: At the end of the program, you will ask if the client wants to purchase a regular router for $50 or a super high-speed router for $200, adding the cost to the total amount the client needs to pay. Once your program calculates the final bill amount, it needs to ask if the client is a member of the military. If so, your program should reduce by 10% the total amount the client needs to pay. Finally, your program must print on the screen the final bill amount to pay, together with the amount reduced for a military discount if applicable (e.g. if the total amount for a military client was $220, your program must show something like this: "Your total bill is $198. This includes a $22 military discount").

Note:

Make sure to format all number outputs so only 2 decimals are shown.

Add all necessary comments to your code, including the header comment and body comments explaining your code.

Test your program several times and paste the testing output show in the console as a comment at the bottom of your source code in the driver/main class program file.

Correctly name your classes, methods, and variables.

Suggestion: Add the steps to the flow chart you created in Assignment 1 and use it to help you plan your program. You may include the updated flow chart in your submission, but it is not required.

Solutions

Expert Solution

import java.util.Scanner;

public class Router {

    public void Calculate(double inital_cost){

        double additional_cost = 0;

        Scanner sc = new Scanner(System.in);
        String s;
        System.out.println("Do you want to purchase a regular router for 50 dollars or a super high speed router for 200 dollars?");
        // Enter 1 for regular or 2 for high speed. Keep taking input till valid input is entered.
        System.out.println("Enter 1 for regular router and 2 for high speed router.");
        s = sc.nextLine();

        while(!s.equals("1") && !s.equals("2")){
            System.out.println("Please enter a valid input.");
            s = sc.nextLine();
        }

        if(s.equals("1")){
            additional_cost += 50;
        }
        else{
            additional_cost += 200;
        }

        double military_discount = 0;
        // Enter y for yes and n for No. Keep taking input till valid input is entered.
        System.out.println("Are you a member of the military? Enter Y/y for yes and N/n for no");

        String m = sc.nextLine();

        m = m.toLowerCase();
        while(!m.equals("y") && !m.equals("n")){
            System.out.println("Please enter a valid input");
            m = sc.nextLine();
            m = m.toLowerCase();
        }
        // calculate total cost and military discount.
        double total_cost = inital_cost + additional_cost;
        if(m.equals("y")){
            military_discount = total_cost/10;
        }

        total_cost = total_cost - military_discount;
        if(military_discount != 0){
            System.out.printf("Your total bill is $%.2f. This includes a $%.2f military discount\n",total_cost, military_discount);
        }
        else{
            System.out.printf("Your total bill is $%.2f\n", total_cost);
        }
    }

    public static void main(String[] args){
        Router r = new Router();

        r.Calculate(100);
    }
    
}

Please copy paste the code from the calculate method to the end of the code in assignment 1, or simply call the calculate method from the end of code from assignment1 while passing the value of bill cost calculated in assignment1.

Appropriate comments have been added for better readability.

I would love to resolve any queries in the comments. Please consider dropping an upvote to help out a struggling college kid :)

Happy Coding!!


Related Solutions

Assignment: Operations Make sure you have completed the Learning Activity in this unit before you start...
Assignment: Operations Make sure you have completed the Learning Activity in this unit before you start this Assignment. Using the graphic below, please discuss the inputs, processes, and outputs that pertain to your operations of the business you chose, whether it is a service or a product oriented business. Using these three steps as a reference, how will you satisfy your customers? What core competencies will you have that will set you apart from your competitors? Pick at least two...
/ READ BEFORE YOU START: // You are given a partially completed program which consist of...
/ READ BEFORE YOU START: // You are given a partially completed program which consist of a class 'Employee' defined in employee.h // The definitions of class member functions are to be filled in employee.cpp (this file). // You should start completing the program from from Q1. Question numbers are given around line 24. // To begin, you should trace through the given code and understand how it works. // Please read the instructions above each required function and follow...
PROGRAM DESCRIPTION: In this assignment, you are provided with working code that does the following: 1....
PROGRAM DESCRIPTION: In this assignment, you are provided with working code that does the following: 1. You input a sentence (containing no more than 50 characters). 2. The program will read the sentence and put it into an array of characters. 3. Then, it creates one thread for each character in the sentence. 4. The goal of the program is to capitalize on each letter that has an odd index. The given program actually does this but lacks the synchronization...
Requirements for the assignment This assignment should be completed in essay format. It should include an...
Requirements for the assignment This assignment should be completed in essay format. It should include an introductory paragraph with a thesis statement, a body, and a concluding paragraph. It should be at least 1,000 words in length. Labor How are wages determined in the U.S.? What are the most significant trends in wages over the past five years? Your answer should address the following: Demand for labor Minimum Wage legislation Role of Unions Outsourcing of jobs Key points to be...
This assignment should not be started until the readings for module 3 have been completed, especially...
This assignment should not be started until the readings for module 3 have been completed, especially Warren Berger’s chapter from A More Beautiful Question. This assignment is designed to test and exercise students’ divergent and convergent thinking skills, as well as the ability to stay problem-minded and to consciously delay solution-mindedness. Fuzzy Situation: Wandering Residents The situation described in the paragraph below has been selected because it is familiar to most people, either through direct personal family experience with a...
Unit 2 Assignment - Simulation Strategic Plan Before you start making decisions in NewShoes, it is...
Unit 2 Assignment - Simulation Strategic Plan Before you start making decisions in NewShoes, it is important to develop a strategic plan. Start by writing a mission statement, in which you communicate a vision for the company. Then identify measurable goals that your company should achieve to support your mission. Finally, plan the strategy you will use to meet those goals. Your strategy should spell out plans to enter markets, marketing mix for each market, and product development budgets. Use...
Assignment instructions: In this assignment, you will first have to go “out” and do something before...
Assignment instructions: In this assignment, you will first have to go “out” and do something before you can write it up. Read here what you need to do: - Break a social norm (Caution: do not wear anything illegal, dangerous, or extremely disruptive.) For example: Wear formal attire to a casual get together. Wear a winter jacket in the summer. Wear sandals in the snow. Wear your pajamas outside. Wear an unstylish or outdated outfit. (What is a social norm?...
This assignment assumes you have completed Programming Challenge 1 of Chapter 9 ( Employee and ProductionWorker...
This assignment assumes you have completed Programming Challenge 1 of Chapter 9 ( Employee and ProductionWorker Classes). Modify the Employee and ProductionWorker classes so they throw exceptions when the following errors occur: ● The Employee class should throw an exception named InvalidEmployeeNumber when it receives an employee number that is less than 0 or greater than 9999. ● The ProductionWorker class should throw an exception named InvalidShift when it receives an invalid shift. ● The ProductionWorker class should throw an...
This assignment has three parts that should all be completed on one document. For this assignment...
This assignment has three parts that should all be completed on one document. For this assignment you will explore the cost-effectiveness of informatics interventions in healthcare. In your role as director of health informatics you are tasked with putting together an executive report that outlines and EHR adoption the effectiveness of EHR. The detailed assignment requirements are below. Part I Summary of laws and mandates requiring EHR adoption EHR & treatment effectiveness and efficiency Be sure to discuss how PHR...
1. Coding Assignment the program will start the menu calling the method extractLargestAndSmallestYourName(), which is specified...
1. Coding Assignment the program will start the menu calling the method extractLargestAndSmallestYourName(), which is specified as below.  The method extractLargestAndSmallestYourName() will receive 2 array of integers as arguments, which are denoted as array number 1 and array number 2.  The method will then search for the largest value and the smallest value. The search will also track from which array(s) these values can be found; and  The information will be return an array, which has the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT