Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

What is the value of p? What is the value of q The solution xis-2.9999999999999742. (4 pts) Problem 2 In the United St Area codes

image text in transcribed
What is the value of p? What is the value of q The solution xis-2.9999999999999742. (4 pts) Problem 2 In the United St Area codes of 800, 888, 877, 866, 855, and 844 denote toll-free nambers (see httpa://www.fcc.gow Ia the United States, phone numbers are comperised of a 3-digit aren code followod by a 7-digit sumb /guides/wbat-toll-tree-nusber-and-hov-does-it-vork). Within your Lab2HW folder, write a program named TollFreeNusbers.java that allows the user to euter a 10-digit U.S. phoae mumber us a single integer. Your program sbould then print whether ut not that number is toll-free. Here are two examples of what your completed program might look lEke wben you run it. Underlined parts indicate what you type in as the program is running. Enter a 10-digit phone number (no apaces or dashes): TT575309 That nunber is toll-freet Enter a 10-digit phone nusber (no spaces or dashes) : 9018675309 That auaber is not toll-free! Hints The int data type only stores values up to 23:-1, which works out to 2,147,483,647. Thas, most 10-digit sumbers will not be storable as int values. Instead, use the long data type. long hehavcs the same as int but uses twice the memory to store its values (64 bits vs. 32 bits), giving it a maxinnuna value of 2a3-1. Use 0xtLong to read a 1ong value from the user. Since the user enters the phone umber into a single variable, can you use integer division and/or mod to get the area code by itself? (4 pts) Problem 3 Suppose you're throwing a wild party for yourself and 9 of your closest friends. Since this purty is wild. you expect each person (incl to disappoint any of your friends (or yourself), so you need to make sure there's enough strawberry juice available 10 people x 14 cans/person = 140 cans. But you can't just buy strawberry juice in individual cans - it's sold only in 6-packs. Thas, you need to buy at least 24 of those 6-packs (giving you a total of 144 cans) to satisfy everyone. The extra 4 cans can be saved for next time, or perhaps used as an incestive to encourage your guests to help you clean up afterward. yourself) to drink 14 cans of ub... strawberry juice. You dou't want After throwing several of these parties, you're getting tired of doing the math yourself every time. Let's do the computer scientist thing and gencralize the problem so we can write a program to solve it. You waat to throw a party for f friends, each of whon will drink c cans of a wholesoue, bealthy beverage which is sold only in p-packs. (As before, assume that you'll partake in the drinking yourself too.) Within your Lab2HU folder, write a program named P and p. The program should then report the minimum with the srumber of extra cans (if any) that you'll have. The program should also allow you to enter the name of the drink (as a string) and include that name in its results. artyPlanner. java that reads user input for f, c sumber of p-packs that need to be bonght, along

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Larry Ellison Database Genius Of Oracle

Authors: Craig Peters

1st Edition

0766019748, 978-0766019744

More Books

Students also viewed these Databases questions

Question

=+31.3. What is the analogue of (31.17)?

Answered: 1 week ago

Question

e. What are notable achievements of the group?

Answered: 1 week ago