Question

Consider the following table. It shows the data on the velocity of an object v as a function of timet 4 12 16 20 24 v [ms034.7 61.8 82.8 99.2112.0121.9 129.7 135.7 140.4


media%2F9c1%2F9c133c3c-50bb-477f-85ad-ad


please use python to write your code and explain your steps, thanks

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.util.Scanner;

public class Postal

{

    public int num2;    // 10000 digit

    public int num3;    // 1000 digit

    public int num4;    // 100 digit

    public int num5;    // 10 digit

    public int num6;    // 1 digit

    public int checkDig; // check digit

    public static int num;

    public static String temp;

    public static int menu;

    public static int zip;

    public static String bar0;

    public static String bar1;

    public static String bar2;

    public static String bar3;

    public static String bar4;

    public static String bar5;

    public static String bar6;

    public static String bar7;

    public static String bar8;

    public static String bar9;

    public static String str;

    public static int numb;

    public Postal()

    {

        zip = 0;

        bar0 = "||:::"; bar1 = ":::||"; bar2 = "::|:|";

        bar3 = "::||:"; bar4 = ":|::|"; bar5 = ":|:|:";

        bar6 = ":||::"; bar7 = "|:::|"; bar8 = "|::|:";

        bar9 = "|:|::";

    }

    public static int getZIP()

    {

        System.out.println("Enter a ZIP code : ");

        Scanner sc = new Scanner(System.in);

        zip = sc.nextInt();

        while((zip<01001)||(zip>99950))

        {

            System.out.println("**** ERROR ****");

            System.out.println("The ZIP code must be between 01001 and 99950");

            System.out.println("Please,enter the correct zip : ");

            zip = sc.nextInt();

        }

        return zip;

    }

    public static int menu()

    {

        System.out.println("**** Zip & Bar Code Convertor ****");

        System.out.println("Choose one option from following : ");

        System.out.println("1) Create ZIP barcode ");

        System.out.println("2) Find ZIP code from barcode ");

        System.out.println("3) Exit ");

        Scanner sc = new Scanner(System.in);

        return sc.nextInt();

    }

    public void getDigit(int num)

    {

        num2 = num/10000;

        num3 = ((num/1000)-num2*10);

        num4 = (num/100 - (num2*100 + num3*10));

        num5 = (num/10 -(num2*1000 + num3*100 + num4*10));

        num6 = (num - (num2*10000 + num3*1000 + num4*100 + num5*10));

        checkDig = 100- (num2+num3+num4+num5+num6);

        System.out.println(checkDig);

        while(checkDig>10)

        {   checkDig -= 10; }

        System.out.println("**** BARCODE ****");

      System.out.print("|");

        getBar(num2);

        getBar(num3);

        getBar(num4);

        getBar(num5);

        getBar(num6);

        getBar(checkDig);

        System.out.print("|");

    }

    public void getBar(int x)

    {

        switch(x)

        {

            case 0: System.out.print(bar0); break;

            case 1: System.out.print(bar1); break;

            case 2: System.out.print(bar2); break;

            case 3: System.out.print(bar3); break;

            case 4: System.out.print(bar4); break;

            case 5: System.out.print(bar5); break;

            case 6: System.out.print(bar6); break;

            case 7: System.out.print(bar7); break;

            case 8: System.out.print(bar8); break;

            case 9: System.out.print(bar9); break;

        }

    }

    public static String number()

    {

        System.out.println("Enter a barcode with using : or | ");

        Scanner scn = new Scanner(System.in);

        String bar = scn.nextLine();

        return bar;

    }

    public static void getNumber(String temp)

    {

        System.out.println("");

        System.out.println(temp);

        if(temp.equals(bar0))

        {

              numb = 0;

       }

        if(temp.equals(bar1))

        {

              numb = 1;

       }

        if(temp.equals(bar2))

        {

              numb = 2;

       }

        if(temp.equals(bar3))

        {

              numb = 3;

       }

        if(temp.equals(bar4))

        {

              numb = 4;

       }

        if(temp.equals(bar5))

        {

              numb = 5;

       }

        if(temp.equals(bar6))

        {

              numb = 6;

       }

        if(temp.equals(bar7))

        {

              numb = 7;

       }

        if(temp.equals(bar8))

        {

              numb = 8;

       }

        if(temp.equals(bar9))

        {

              numb = 9;

       }

        System.out.print(numb);

    }

    public static void divide(String temp)

    {

        Postal po = new Postal();

        str = temp.substring(1,6);

        po.getNumber(str);

        str = temp.substring(6,11);

        po.getNumber(str);

        str = temp.substring(11,16);

        po.getNumber(str);

        str = temp.substring(16,21);

        po.getNumber(str);

        str = temp.substring(21,26);

        po.getNumber(str);

    }

    public static void main(String[] args)

    {

        Postal pos = new Postal();

        while(menu != 3)

        {

            System.out.println();

            menu = pos.menu();

            switch (menu)

           {

                case 1:

                    num = pos.getZIP();

                    pos.getDigit(num);

                    System.out.println();

                    break;

                case 2:

                    temp = pos.number();

                    System.out.println(temp);

                    pos.divide(temp);

                    break;

                case 3:

                    break;

            }

        }

    }

}

Add a comment
Know the answer?
Add Answer to:
please use python to write your code and explain your steps, thanks Consider the following table....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please write the following in python 3 Also please share your code and soltion Given two...

    Please write the following in python 3 Also please share your code and soltion Given two variables, firstPlace and secondPlace, write some code that swaps (switches) their associated values. Use additional variable(s) as necessary (NOTE: Do not use any predefined swap function!)

  • *PYTHON EXPERTS ONLY PLEASE* Please provide the answer coded in Python using comments to explain code...

    *PYTHON EXPERTS ONLY PLEASE* Please provide the answer coded in Python using comments to explain code function. Good answers will be rated with thumbs up! Please answer both parts. Thank you for your time. Question 3 - Suppose you have a file named numbers.csv which contains a bunch of integers, five per line of text, separated by commas. Write code below that will open the _le, read the numbers from it, and print the sum of all the even numbers...

  • PLEASE WRITE NEATLY AND EXPLAIN YOUR METHOD/SHOW ALL STEPS. THANKS! 3) What is the IRR for...

    PLEASE WRITE NEATLY AND EXPLAIN YOUR METHOD/SHOW ALL STEPS. THANKS! 3) What is the IRR for an investment that has a $5000 investment with $1000/year for 6 years?

  • 1. Please write the following in Python 3 code. Also, write code and not psedo code....

    1. Please write the following in Python 3 code. Also, write code and not psedo code. Also, show all outputs and share your code. Question: Create one conditional so that if “Friendly” is in w, then “Friendly is here!” should be assigned to the variable wrd. If it’s not, check if “Friend” is in w. If so, the string “Friend is here!” should be assigned to the variable wrd, otherwise “No variation of friend is in here.” should be assigned...

  • This is for programming using Python with the JES software. Please write the code with the...

    This is for programming using Python with the JES software. Please write the code with the proper indentation. Thanks! Problem 1: Write a function that takes 2 arguments (integer or float) and computes the sum, difference, product, and quotient of the arguments. Once you calculate the values you should print out statements telling the user what arguments we used to compute the values and what the result of each calculation (your function should produce 5 lines of output in the...

  • cope the code please thanks Write a MATLAB code to obtain the following. Keep your code...

    cope the code please thanks Write a MATLAB code to obtain the following. Keep your code commented whenever required. Copy your source code and command widow outcomes and screen shots of any plots in your solution. Generate a matrix "A" as follow. A= 16 6 8 2 10 18 12 14 4 I. II. Divide the matrix A by 2 and store the result in a matrix B. Combine matrices A & B to obtain the following matrix C. Also...

  • 1. Please write the following code in Python 3. Please also show all outputs and share...

    1. Please write the following code in Python 3. Please also show all outputs and share your code. Write the following program: The first function, divide that takes in any number and returns that same number divided by 2. The second function called sum should take any number, divide it by 2, and add 6. It should return this new number. You should call the divide function within the sum function. Do not worry about decimals.

  • this is the question, please help me with this python coding question thanks and appreciate your...

    this is the question, please help me with this python coding question thanks and appreciate your help 1. Create an object call Accounts. This is to be used in a banking system. 2. Initialize the account with three data as inputs : Firstname, Lastname and balance. 3. Create 4 additional member functions: Deposit, Withdraw, Fee Calculations, interest The fee calculation is going to be $10 per month if the total amount in the account is less than $1000. Interest is...

  • For this problem, assume salesperson data are stored in a database table named staff. Also assume the columns in the table are named name, carsSold, and totalSales Write a Python function named ge...

    For this problem, assume salesperson data are stored in a database table named staff. Also assume the columns in the table are named name, carsSold, and totalSales Write a Python function named getSalesSortedByNames. Your function will have 2 parameters. The first parameter is a database cursor and the second parameter is a float. Your function should start by retrieving those rows in the staff table whose totalsales field is equal to the second parameter. (The next paragraph shows the Python...

  • Python code please!! Provide code and screenshots to both code and its output!!! Write a program...

    Python code please!! Provide code and screenshots to both code and its output!!! Write a program that prompts the user to select either Miles-to-Kilometers or Kilometers-to-Miles, then asks the user to enter the distance they wish to convert. The conversion formula is: Miles = Kilometers X 0.6214 Kilometers = Miles / 0.6214 Write two functions that each accept a distance as an argument, one that converts from Miles-to-Kilometers and another that converts from Kilometers-to-Miles The conversion MUST be done as...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT