Question
Please use java Objective: The objective of this lab is to use existing classes to declare and instantiate objects, then invoke methods to manipulate object
Please use java
Objective: The objective of this lab is to use existing classes to declare and instantiate objects, then invoke methods to manipulate object data and get object information, also practice use static (class) methods.
You are writing an application for a phone store. This application will read a file phone.txt. So it has the public static void main(String[] args) throws IOException .Please store the phone.txt file in the same lab3 folder outside the src folder (see picture below). The file includes the phone information, as shown in the sample input below: iPhone11Pro 700 14.5.
The information is segregate via a space, first part is the model number, the next part is the price, and the last part is the promotion on phones.
1. (0.15 point) Create a File object have the phone.txt as a path for you the file. 2. (0.15 points) Create a Scanner object that uses the File object create in 1 as an input, to allow reading the file information. 3. (0.15 point) Create a variable firstLine and store the first line in the file using nextLine method of the Scanner class. 4. (0.1 point) Declare a constant TAXRATE of 10% 5. (0.2 point) Declare 3 String variables firstWord, secondWord, and thirdWord. The first word in the file is the model, the second word is the price and the last one is the discount. Find the space index in the firstLine using methods of the String than extract the model into the firstWord, do the same steps for secondWord and thirdWord. 6. (0.15 point) Use the Double class method to parse the String secondWord and thirdWord into double variables price and discount. 7. (0.35 point) Use the variable of part 5: firstWord, price and discount. Format the price to get the format below and calculate the sale price and the price after tax (See below sample run: Model Price discount sale Price After Tax iPhone11P $700.00 14.5% $598.50 $698.90 Hint to get the above formatted output use NumberFormat objects 8. (0.2 point) Use the math class method to find the largest among the 2 prices: price and After Tax price. Show the message below in the console : The maximum price among the 2 is: $ 700.00 9. (0.15 point) prompt user to enter the double exchange rate from dollar to euro, create a scanner object to read the rate 10. (0.4 point) Use the exchange rate to calculate the price and store it in a convertedPrice than create a NumberFormat object for currency in FRANCE using the getCurrencyInstance method, format the convertedPrice to currency format and show the results as The price in France is 770,00 Notes: - You must create the input file phones.txt. - You do not need to use functions in this program. - You must use a named constant for the tax rate (10%). - Since some results displayed are monetary values, your output must be displayed with two decimal places of precision. Be sure decimals line up when you output the information.
> This PC > Windows-SSD (C:) > Users > marwa > eclipse-workspace > Lab3 Name Type Size File folder settings bin SIC .classpath project phone Date modified 2/12/20211:52 AM 2/12/2021 1:52 AM 2/12/2021 1:53 AM 2/12/2021 1:52 AM 2/12/2021 1:52 AM 2/12/2021 5:11 AM File folder File folder CLASSPATH File PROJECT File Text Document 1 KB 1 KB 1 KBStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started