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
What does it mean by MYRIAD of data?
pentagon [3]

Answer:

The term Myriad means an indefinitely large number of things. And when we say Myriad of data, we mean an indefinitely large amount of data like in Petabytes.

Explanation:

What it does implies is that you are dealing with a large amount of data. And hence we are dealing with something like bigData. And hence, technologies related to BigData are going to operate. And this term is used as a noun as well as an adjective when we talk about English. And hence, you can use it with "a" or without the "a" as well. It has been a part of reputable English and has been repeatedly used by top authors like Milton.

5 0
4 years ago
A computer is made up of hardware and software ​
denis-greek [22]
Um well yeahhhhuhh lol
4 0
3 years ago
OSHA requires training for employees on the hazards to which they will be exposed.
Sedaia [141]

A, OSHA does require training for employees on the hazards to which they will be exposed.


3 0
4 years ago
Read 2 more answers
How to save a file for the first time?​
White raven [17]

by typing ctrl+ s on keyboard

7 0
3 years ago
Read 2 more answers
Write a class declaration named Circle with a private member variable named radius. Write set and get functions to access the ra
Kazeer [188]

Answer:

See explaination

Explanation:

#include <iostream>

using namespace std;

class Circle{

// private member variable named radius

private:

double radius;

// get function for radius

public:

double getRadius(){

return radius;

}

// set function for radius

void setRadius(double rad){

radius=rad;

}

// returning area = 3.14159 * radius * radius

double getArea(){

return (3.14159 * radius * radius);

}

};

// Sample run

int main()

{

// Declaring object of Circle

Circle myCircle;

myCircle.setRadius(5);

// printing radius of circle

cout<<"Radius of circle is: "<<(myCircle.getRadius())<<endl;

// printing area of circle

cout<<"Area of circle is: "<<(myCircle.getArea())<<endl;

return 0;

}

4 0
3 years ago
Other questions:
  • Tell me the shortcut keys used in Ms PowerPoint ?​
    6·2 answers
  • You receive a file named Project4.xlsx as an attachment to an email message. What do you expect the file to contain?
    8·1 answer
  • It is important that data being imported from a text file into access are separated by a character, such as a comma, which defin
    8·1 answer
  • 6. A distribution consists of three components with frequencies 200, 250 and 300 having means
    14·1 answer
  • In cryptography, the term "Secret algorithm" refers to an algorithm designed in a way that prevents the examination of its inner
    12·2 answers
  • The correct ordering of the seven layers from "top" to "bottom" is
    11·1 answer
  • What do you need to do before you can sort and filter data in a data base?
    12·1 answer
  • Explain motherboard in detail
    14·2 answers
  • The Python language uses a compiler which is a program that both translates and executes the instructions in a high-level langua
    15·1 answer
  • WHICH PROGRAMMING LANGUAGES ARE THE BEST AND COMPATIBLE FOR 3D PRINTERS?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!