1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
horrorfan [7]
4 years ago
10

Write a program called DeliveryCharges for the package delivery service. The program should use an array that holds the 10 zip c

odes of areas to which the company makes deliveries. (Note that this array has been created for your and does not need to be changed.) A Parallel array has also been creating contating 10 delivery charges that differ for each zip code. Prompt a user to enter a zip code, and then display either a message indicating the price of delivery to that zip code or a message indicating that the company does not deliver to the requested zip code.
Computers and Technology
1 answer:
Vlad [161]4 years ago
8 0

Answer:

import java.util.Scanner;

public class DeliveryCharges

{

public static void main(String[] args) {

 

       String[] zips = {"01234", "11234", "21234", "31234", "41234", "51234", "61234", "71234", "81234", "91234"};

    double[] prices = {2.2, 1.0, 3.6, 6, 9, 7.1, 0.8, 4.7, 3.3, 5.2};

    int index = -1;

    Scanner ob = new Scanner(System.in);

    System.out.print("Enter the zip code for your delivery: ");

    String zip = ob.next();

   

    for (int i=0; i<10; i++) {

        if (zip.equals(zips[i])) {

            index = i;

        }

    }

       

    if (index!= -1)

       System.out.println("Delivery charge to " + zips[index] + " is: " + prices[index]);

    else

       System.out.println("No delivery to " + zip);

}

}

Explanation:

Initialize the zips and prices

Initialize index that represents the index of the zip code. If the entered zip code is in the array

Ask the user to enter the zip code

Create a for loop that iterates through the zips. If the entered zip is in the zips, set its index to index

When the loop is done, check if the index. If the index is not -1, that means zip code was found in the zips array, print the corresponding price from the price array. Otherwise, print no delivery for the entered zip code

You might be interested in
Windows OS and Mac OS are examples of which type of operating system?
german
Windows OS and Mac OS are examples of single user, multi tasking Operating Systems.
5 0
4 years ago
Read 2 more answers
Write a program that asks the user to enter a positive integer that represents a number in the decimal system and then displays
Maru [420]

Answer:

In Python:

def decimalToBinary(num):

   if num == 0:

       return 0

   else:

       return(num%2 + 10*decimalToBinary(int(num//2)))

       

decimal_number = int(input("Decimal Number: "))

print("Decimal: "+str(decimalToBinary(decimal_number)))

Explanation:

This defines the function

def decimalToBinary(num):

If num is 0, this returns 0

<em>    if num == 0: </em>

<em>        return 0 </em>

If otherwise

   else:

num is divided by 2, the remainder is saved and the result is recursively passed to the function; this is done until the binary representation is gotten

       return(num%2 + 10*decimalToBinary(int(num//2)))

       

The main begins here.

This prompts the user for decimal number

decimal_number = int(input("Decimal Number: "))

This calls the function and prints the binary representation

print("Decimal: "+str(decimalToBinary(decimal_number)))

3 0
3 years ago
Which group on the Home Ribbon allows you to create bulleted and numbered lists in a PowerPoint presentation?
igomit [66]
You gotta do the paragraph group its that one
3 0
3 years ago
Read 2 more answers
Select the correct text in the passage.
sergejj [24]

Answer:

2. Scientists use seismometers to measure the earthquake activity that occurs beneath a volcano. They then predict the eruption of that volcano.

Explanation:

The options are:

1. Before a volcano erupts, earthquake activity beneath the volcano decreases.2. Scientists use seismometers to measure the earthquake activity that occurs beneath a volcano. They then predict the eruption of that volcano.3. When a volcano erupts, the amount of carbon dioxide and sulfur dioxide emitted decreases. 4.Scientists measure the amount of these gases to determine the amount of magma present in the volcanic reservoir.

The answer is certainly 2. as seismometers are being used to find out the details of the earthquake activities which occur inside a volcano. And with this information, the volcanologists then predict the eruption of that particular volcano. Hence, the 2nd option does not have any factual errors, and all the others have factual errors.

5 0
3 years ago
Which if statement does not check for the condition "the month is between May and August and num_finals_left is zero?" Assume th
larisa [96]

Answer:

Option b  if month in ["May", "June", "July", "August"] and not num_finals:

Explanation:

The if statement in the option b doesn't meet the objective to check if num_finals is zero. It just use a not operator which is not relevant here.  The num_finals is an integer and therefore to check if num_finals is zero, the correct statement should be num_finals == 0  The "==" is an equality operator to check if a left value is equal to the right value. The rest of the three options are correct as they meet the checking requirements.

3 0
4 years ago
Other questions:
  • Rose has a list of two columns of information separated by tabs. She wants to input this information into a table. What is the f
    15·2 answers
  • What term refers to a piece of software that interfaces with the hardware on your computer?
    10·2 answers
  • What is the main benefit of seeing your document in Page Break Preview?
    9·2 answers
  • Which commercial email provider is most closely associated with Apple devices?
    9·1 answer
  • What would you use to exit from a for each activity and continue the execution of the workflow?
    13·1 answer
  • Which is the best practice for placing graphics on a slide?
    6·2 answers
  • You are troubleshooting a mobile device with no sound output from the headset or external speakers.
    6·1 answer
  • Data management technology consists of the: Group of answer choices physical hardware and media used by an organization for stor
    13·1 answer
  • How long does it take to send a 19 MiB file from Host A to Host B over a circuit-switched network, assuming:
    14·1 answer
  • Please please help ASAP it’s timed
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!