Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You can use while loop to simulate the downloading time (see below). You may also need to do decisions (if-else statement) in each loop

image text in transcribed image text in transcribed

You can use while loop to simulate the downloading time (see below). You may also need to do decisions (if-else statement) in each loop iteration according to the requirements listed in the assignment description below. (20 pts) Assume one is sitting in a room with very unstable Wi-Fi signal and is downloading a big file via a cell phone. Sometimes the Wi-Fi signal is ON, but sometimes it is OFF. According to modern settings, a phone will use Wi-Fi if the Wi-Fi signal is ON, but it will use 4G LTE if the Wi- Fi signal is OFF. Assume the person will stay in the room for 2 minutes (i.e. 120 seconds). The phone will switch between the Wi-Fi signal and the 4G LTE signal back and forth to download the big file, depending on the status of the Wi-Fi signal. The switching time between one signal to another can be ignored. Assume that the phone will check whether the Wi-Fi signal is ON at every second, and if it is ON, the phone will use Wi-Fi to download data in that second. Otherwise, the phone will use 4G LTE to download data in that second. Whether the Wi-Fi signal is ON or OFF is random, but the 4G LTE signal is always available. The signal checking time can be ignored. The downloading speed in Wi-Fi is 1.2 Mbytes/second, and it is 0.8 Mbytes/second in 4G LTE environment. The Wi-Fi signal is free, but the 4G LTE signal charges 0.5 dollar/second. Please write a program that simulates the downloading process in those 2 minutes. You do not have to simulate the "clock" time in your code, just use 120 iterations to simulate the procedure. The program should print the following statistics at the end (i.e. after the loop), and then the program terminates. a. The total bytes the phone downloads (in Mbytes). b. The total bytes downloaded in Wi-Fi environment (in Mbytes). c. The total bytes downloaded in 4G LTE environment (in Mbytes). d. The price for using the 4G LTE signal (in dollars). Submission Requirement: Please upload your Java source code (.java file) to Blackboard Assignment 5 section. Clues: You may want to use the return value of Math.random() to simulate the fact whether the Wi-Fi signal is ON or OFF. STOP at here and think about how to use and interpret its return value. If you need further information, please follow the arrow below. You can follow our examples on slides to randomly generate either of two values (0 or 1), then you can use value 0 to indicate "Wi-Fi ON", and value 1 to indicate "Wi-Fi OFF".

Step by Step Solution

3.36 Rating (152 Votes )

There are 3 Steps involved in it

Step: 1

Heres the program that simulates the downloading process according to the requirements you provided ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Strategic Management Concepts And Cases A Competitive Advantage Approach

Authors: Fred R. David

13th Edition

0136120989, 9780136120988

More Books

Students also viewed these Programming questions