Questions
Here is a (buggy) version of the Eratosthenes sieve: # should return a list of prime...

Here is a (buggy) version of the Eratosthenes sieve:

# should return a list of prime numbers from 1..n (including n)

def sieve(n):

if n < 2: #there are no prime numbers < 2

return []

primes = [2] # 2 is the first prime number

for i in range(n): #put all of the numbers into primes initially

primes.append(i)

for current in range(n):

# start at current, and remove all multiples of current up to n

for j in range(current,n,current): primes.remove(j)

return primes

print(sieve(20))

Using PyCharm, under lab8, under Directory exercise, create a Python file called erat.py, and add the function above to it. Test the function with print(sieve(20)), as shown above.

Pycharm allows you to run programs in debug mode so that you can see the value of variables. First, we need to decide where we want to start looking, maybe the for current loop, the outer loop. In my code, that is on line 8. In the Pycharm editor window, go to the grey area to the right of the line number with the outer for loop, and right click. A red circle should appear. This is called a breakpoint. When you debug your program, the program will stop before executing this statement. To start debug, right click in the code area, and choose Debug instead of Run:

The program should begin running. A debug window should appear in the lower part of your PyCharm window that shows you the value of your variables. It should look something like this:

The variable i is set from the previous loop. primes is not filled with the correct values, but n is correct.

When debugging, you can continue running the program, or stop. To stop, press the red square. Don’t do that now (if you did, just debug again, and get back to the screen above). Instead, perform the next step, in the program by clicking the “Step Into My Code” icon:

current should appear with a value of 0, and the line number to be executed next should be 9 now. Play around with these buttons to see what happens as you execute the sieve function.

There could be other problems, but one problem we have already noticed is that primes is filled with incorrect values. This happened in the first for loop. Before the nested for loops, primes should be [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]. Use the debugger to figure out what went wrong, and fix that problem.

Instead of using the debugger, you can also add print statements to determine the values of the variables. Make sure you label all of the values, or it will be difficult to determine what values are being printed. For example, you might be the following inside the inner loop:

print('right now, current is', current, 'j is ', j, 'primes is', primes)

print('removing', j)

to see the value of the variables as you loop through.

Debug sieve, fix it, and run the tests for sieve. You will need to change the values within range statements, and add an if statement to make the code run correctly. You should not need to change anything else. Test your solution, and submit it.

In: Computer Science

Were there any strong relationships indicated? Were there any extreme values that might skew results? How...

  1. Were there any strong relationships indicated?
  2. Were there any extreme values that might skew results?
  3. How would you use the regression equations generated by the software?
  4. What preliminary conclusions would be supported and what further study indicated?

Response: Hemoglobin Model: carb_intake General Regression Analysis: Hemoglobin versus Carb_Intake Regression Equation Hemoglobin = 5.93337 + 0.00630756 Carb_Intake Coefficients Term Coef SE Coef T P Constant 5.93337 0.161506 36.7377 0.000 Carb_Intake 0.00631 0.000722 8.7397 0.000 Summary of Model S = 1.13003 R-Sq = 13.30% R-Sq(adj) = 13.12% PRESS = 641.917 R-Sq(pred) = 12.48% Analysis of Variance Source DF Seq SS Adj SS Adj MS F P Regression 1 97.537 97.537 97.5368 76.3822 0.0000000 Carb_Intake 1 97.537 97.537 97.5368 76.3822 0.0000000 Error 498 635.925 635.925 1.2770 Lack-of-Fit 223 336.136 336.136 1.5073 1.3827 0.0053349 Pure Error 275 299.789 299.789 1.0901 Total 499 733.462 Fits and Diagnostics for Unusual Observations Obs Hemoglobin Fit SE Fit Residual St Resid 14 12 8.55100 0.154608 3.44900 3.08111 R X 22 12 8.13470 0.110692 3.86530 3.43707 R 55 12 8.14101 0.111334 3.85899 3.43165 R 65 8 8.79069 0.180749 -0.79069 -0.70884 X 81 8 8.28609 0.126350 -0.28609 -0.25477 X 84 11 6.97411 0.061084 4.02589 3.56787 R 98 7 8.26716 0.124369 -1.26716 -1.12821 X 99 11 7.15072 0.052468 3.84928 3.41004 R 138 6 8.36808 0.135001 -2.36808 -2.11072 R X 142 10 7.52918 0.058365 2.47082 2.18944 R 152 10 6.84165 0.070719 3.15835 2.80042 R 161 11 7.42195 0.053296 3.57805 3.16987 R 192 10 6.86688 0.068730 3.13312 2.77775 R 213 7 8.31132 0.129001 -1.31132 -1.16807 X 223 12 7.78779 0.077524 4.21221 3.73634 R 237 11 7.18226 0.051615 3.81774 3.38198 R 241 10 7.12549 0.053316 2.87451 2.54659 R 243 11 7.98332 0.095609 3.01668 2.67917 R 278 10 7.26426 0.050549 2.73574 2.42338 R 285 8 8.64562 0.164877 -0.64562 -0.57751 X 301 9 8.29239 0.127012 0.70761 0.63018 X 321 12 7.59856 0.062714 4.40144 3.90100 R 334 9 8.35547 0.133664 0.64453 0.57440 X 356 10 7.29580 0.050598 2.70420 2.39545 R 368 12 8.10947 0.108131 3.89053 3.45874 R 375 11 7.66795 0.067718 3.33205 2.95396 R 385 11 7.47872 0.055701 3.52128 3.11990 R 435 10 7.62379 0.064465 2.37621 2.10622 R 460 10 7.38410 0.052083 2.61590 2.31736 R 499 10 7.20749 0.051106 2.79251 2.47372 R R denotes an observation with a large standardized residual. X denotes an observation whose X value gives it large leverage. Normplot of Residuals for Hemoglobin Residual Histogram for Hemoglobin

In: Statistics and Probability

///create a main menu to enter choices such as "Welcome to any college" then please enter...

///create a main menu to enter choices such as "Welcome to any college" then please enter your choice of information when you press a key 1. view students. 2. insert student 3. remove student 4. exit...and student ID#, age, birthday, location, expected gradation date

import java.util.Scanner;

public class CourseCOM666 {
private String courseName;
private String [] students = new String[1];
private int numberOfStudents;

public CourseCOM666(String courseName) {
this.courseName = courseName;
}
public String[] getStudents(){
return students;
}
public int getNumberOfStudents(){
return numberOfStudents;
}
public String getCourseName(){
return courseName;
}

public void addStudent(String student) {
// Automatically increases the array size
if (numberOfStudents == students.length) {
String[] a = new String[students.length + 1];
for (int i = 0; i < numberOfStudents; i++) {
a[i] = students[i];
}
students = a;
}
students[numberOfStudents] = student;
numberOfStudents++;
}
public String[] addStudentByIndex(String student,int index){
String [] a = new String[students.length+1];
if (numberOfStudents == students.length){

for (int i = 0; i < a.length;i++){
if(i < index){
a[i] = students[i];
}
else if (i == index ){
a[i] = student;
}
else{
a[i] = students[i-1];
}}
}
numberOfStudents++;
return a;

}
public static void display(String[]students){
System.out.println("========================");
System.out.print("Now the New students Array is :\n");
for(int i=0; i<students.length; i++)
{
System.out.println("Index: "+(i)+"--> "+ students[i]+" ");
}
}



public String [] removeStudentByIndex(String [] a,int index){
//find the index of student
String [] b = new String[a.length-1];
students = a;
// int position = findStudent(student);
for (int i = 0,k=0; i < a.length;i++){
if (i == index){
continue;
}
else{
b[k++] = a[i];
}
}
numberOfStudents--;


return b;

}
private int findStudent(String student) {
for (int i = 0; i < numberOfStudents; i++) {
if (students[i].equals(student)) {
return i;
}
}
return -1;
}



}
import java.util.Scanner;

public class d {
public static void main(String [] args){
CourseCOM666 com666 = new CourseCOM666("com666");
com666.addStudent("hank");
com666.addStudent("paul");
com666.addStudent("david");
com666.addStudent("ben");
com666.addStudent("jacob");

int sum = 0;
////////create a new array String students1[] to hold all students/////////////////////
String students1[] = com666.getStudents();

sum += com666.getNumberOfStudents();
for(int i =0; i<students1.length; i++) {
System.out.println("Index is: "+(i)+ " --> "+students1[i]);
}

System.out.println("Number of students attending the Course is: " + sum);

Scanner scan = new Scanner(System.in);
System.out.println("Enter the name of student and index:");
String student = scan.nextLine();
students1 = com666.addStudentByIndex(student,3);
com666.display(students1);

sum = com666.getNumberOfStudents();
System.out.println("After student was added the Student number is:" + sum);


System.out.println("remove student by index");
int index = scan.nextInt();
students1=com666.removeStudentByIndex(students1,index);
com666.display(students1);
sum = com666.getNumberOfStudents();
System.out.println("After student drop number is:" + sum);
System.out.println("Number of students attending the Course is: " + sum);
System.out.println("----------------------------");

//use do while loops

In: Computer Science

java For this assignment, you will create a Time class that holds an hour value and...

java

For this assignment, you will create a Time class that holds an hour value and a minute value to represent a time. We will be using "military time", so 12:01 AM is 0001 and 1 PM is 1300. For this assignment, you may assume valid military times range from 0000 to 2359. Valid standard times range from 12:00 AM to 11:59 PM.

In previous assignments, we had a requirement that your class be named Main. In this assignment, the class is required to be named Time.

To get started, download the template file, Time.java. Your job will be to add the constructors and methods described in the following sections to the class, Time, that is declared in this template file.

Time should include two constructors:

Time() - Default constructor that sets the time to 0000.

Time(int h, int m) - If h is between 1 and 23 inclusive, set the hour to h. Otherwise, set the hour to 0. If m is between 0 and 59 inclusive, set the minutes to m. Otherwise, set the minutes to 0.

Time should include the following methods:

String toString() - Returns the time as a String of length 4 in the format: 0819. Notice that if the hour or minute is one digit, it should print a zero first. For example, 6 should print as 06.

String convert() - Returns the time as a String converted from military time to standard time. For example, 0545 becomes 5:45 AM and 1306 becomes 1:06 PM.

void increment() - Advances the time by one minute. Remember that 60 minutes = 1 hour. Therefore, if your time was 0359, and you add one minute, it becomes 0400. 2359 should increment to 0000.

To test your code, download the runner class student_time_runner.java into the same folder that holds your Time.java. Execute the method student_time_runner.main, and verify that the output matches the sample run listed below.

We will use a similar but different runner to grade the program. In order to pass all tests, you will need to change student_time_runner.java to test different values to make sure your program fits the requirements. Note: You will not be submitting student_time_runner.java. This file is provided to help you test your implementation of the class Time.

When you are done coding and testing, copy and paste your entire Time class into the Code Runner and press "Submit Answers" in order for your assignment to count as turned in.

Sample Run:

time1: 1456
convert time1 to standard time: 2:56 PM
time1: 1456
increment time1 five times: 1501

time2: 0012
increment time2 67 times: 0119
convert to time2 standard time: 1:19 AM
time2: 0119

time3: 0517
convert time3: 5:17 AM

time4: 1215
convert time4: 12:15 PM

time5: 0015
convert time5: 12:15 AM

time6: 0015
convert time6: 12:15 AM

time7: 2359
convert time7: 11:59 PM
increment time7: 0000
convert time7: 12:00 AM

NOTE: You must use the class name "Time" for this assignment. REMEMBER: You must SUBMIT your answer. Your assignment does not count as complete unless it has been submitted.

In: Computer Science

A pizza restaurant monitors the size (measured by the diameter) of the 10-inch pizzas that it...

A pizza restaurant monitors the size (measured by the diameter) of the 10-inch pizzas that it prepares. Pizza crusts are made from doughsthat are prepared and prepackaged in boxes of 15 by a supplier. Doughsare thawed and pressed in a pressing machine. The toppings are added, and the pizzas are baked. The wetness of the doughsvaries from box to box, and if the dough is too wet or greasy, it is difficult to press, resulting in a crust that is too small. The first shift of workers begins work at 4 P.M., and a new shift takes over at 9 P.M. and works until closing. The pressing machine is readjusted at the beginning of each shift. The restaurant takes five consecutive pizzas prepared at the beginning of each hour from opening to closing on a particular day. The diameter of each baked pizza in the subgroups is measured, and the pizza crust diameters obtained are given in Table.

Subgroup

Pizza crust diameter in inches

Time

1

2

3

4

5

1

4 pm

9.8

9.0

9.0

9.2

9.2

2

5 pm

9.5

10.3

10.2

10.0

10.0

3

6 pm

10.3

10.5

9.8

10.0

10.3

4

7 pm

10.7

9.5

9.8

10.0

10.0

5

8 pm

10.0

10.5

10.0

10.5

10.3

6

9 pm

10.0

9.0

9.0

9.2

9.3

7

10 pm

11.0

10.0

10.3

10.3

10.0

8

11 pm

10.0

10.2

10.1

10.3

11.0

9

12 am

10.0

10.4

10.4

10.5

10.0

10

1 am

11.0

10.5

10.1

10.2

10.2

Use the pizza crust diameter data to do the following:

a. Show that X bar =10.028 and R bar = 0.84.

b. Find the center lines and control limits for the X bar and Rcharts for the pizza crust data.

c. Set up the X bar and Rcharts for the pizza crust data.

d. Is the R chart for the pizza crust data in statistical control? Explain.

e. Is the X bar chart for the pizza crust data in statistical control? If not, use the X bar chart and the information given with the data to try to identify any assignable causes that might exist.

f. Suppose that, based on the X bar chart, the manager of the restaurant decides that the employees do not know how to properly adjust the dough pressing machine. Because of this, the manager thoroughly trains the employees in the use of this equipment. Because an assignable cause (incorrect adjustment of the pressing machine) has been found and eliminated, we can remove the subgroups affected by this unusual process variation from the data set. We therefore drop subgroups 1 and 6 from the data. Use the remaining eight subgroups to show that we obtain revised center lines of X bar = 10.2225 and R bar = 0.825.

g. Use the revised values of and to compute revised and R chart control limits for the pizza crust diameter data. Set up X bar and R charts using these revised limits. Be sure to omit subgroup means and ranges for subgroups 1 and 6 when setting up these charts.

h. Has removing the assignable cause brought the process into statistical control? Explain.

In: Math

Option #2: Financial Statement Analysis Problems Complete the following problems: 1. For this problem, use the...

Option #2: Financial Statement Analysis Problems

Complete the following problems:

1. For this problem, use the following randomly generated list of accounts, placing them in appropriate order to prepare an income statement.

Accounts

($000,000)

Depreciation

25

General and administrative expenses

22

Sales

345

Sales expenses

18

Cost of goods sold

255

Lease expense

4

Interest expense

3

  1. The following randomly constructed table requires that as part of your Critical Thinking Assignment you arrange the accounts into a well-labeled income statement. Make sure you label and solve for gross profit, operating profit, and net profit before taxes.
  2. Using a 35% tax rate, calculate taxes paid and net profit after taxes.
  3. Assuming a dividend of $1.10 per share with 4.25 million shares outstanding, calculate EPS and additions to retained earnings.

2. Explain why the income statement can also be called a “profit-and-loss statement.” What exactly does the word balance mean in the title of the balance sheet? Why do we balance the two halves?

3. CS Industries, Inc. began 2016 with retained earnings of $25.32 million. During the year, it paid four quarterly dividends of $0.35 per share to 2.75 million common stockholders. Preferred stockholders, holding 500,000 shares, were paid two semiannual dividends of $0.75 per share. The firm had a net profit after taxes of $5.15 million. Prepare the statement of retained earnings for the year ended December 31, 2016.

4. Sky Metals, Inc. is a metal fabrication firm that manufactures prefabricated metal parts for customers in a variety of industries. The firm’s motto is “If you need it, we can make it.” The CEO of Sky Metals recently held a board meeting during which he extolled the virtues of the corporation. The company, he stated confidently, had the capability to build any product and could do so using a lean manufacturing model. The firm would soon be profitable, claimed the CEO, because the company used state-of-the-art technology to build a variety of products while keeping inventory levels low. As a business press reporter, you have calculated some ratios to analyze the financial health of the firm. Sky Metals' current ratios and quick ratios for the past 6 years are shown in the following table:

2010

2011

2012

2013

2014        2015

2015

Current ratio

1.2

1.4

1.3

1.6

1.8           2.2

2.2

Quick ratio

1.1

1.3

1.2

0.8

0.6          0.4

0.4

What do you think of the CEO’s claim that the firm is lean and soon to be profitable?

5. If we know that a firm has a net profit margin of 4.5%, total asset turnover of 0.72, and a financial leverage multiplier of 1.43, what is its ROE? What is the advantage to using the DuPont system to calculate ROE over the direct calculation of earnings available for common stockholders divided by common stock equity?

In: Finance

ETHICS 445 Scenario It is 2020, and General Foryota Company opens a plant in which to...

ETHICS 445

Scenario

It is 2020, and General Foryota Company opens a plant in which to build a new mass-produced hover-craft. This hover-craft will work using E-85 Ethanol, will travel up to 200 mph, and will reduce pollution worldwide at a rate of 10 percent per year. It is likely that when all automobiles in the industrial world have been changed over to hovercrafts, emission of greenhouse gasses may be so reduced that global warming may end and air quality will become completely refreshed.

However, the downside is that during the transition time, GFC's Hover-Vee (only available in red or black), will most likely put all transportation as we know it in major dissaray. Roadways will no longer be necessary, but new methods of controlling traffic will be required. Further, while the old version of cars are still being used, Hover-vee's will cause accidents, parking issues, and most likely class envy and warfare. The sticker price on the first two models will be about four times that of the average SUV (to about $200,000.) Even so, GFC's marketing futurists have let them know that they will be able to pre-sell their first three years of expected production, with a potential waiting list which will take between 15 and 20 years to fill.

The Chief Engineer (CE) of GFC commissions a study on potential liabilities for the Hover-vees. The preliminary result is that Hover-vees will likely kill or maim humans at an increased rate of double to triple over automobile travel because of collisions and crashes at high speeds -- projected annual death rates of 100,000 to 200,000. However, global warming will end, and the environment will flourish.

The U. S. Government gets wind of the plans. Congress begins to discuss the rules on who can own and operate Hover-vees. GFC's stock skyrockets. The Chief Engineer takes the results of the study to the Chief Legal Counsel (CLC), and together they agree to bury the study, going forward with the production plans. The Chief Project Manager (CPM), who has read the study and agreed to bury it, goes ahead and plans out the project for the company, with target dates and production deadlines.

Somebody sent a secret copy of the report to you at your home address. It has no information in it at all, except for the report showing the proof of the increase in accidents and deaths. The report shows, on its face, that the CE, CLC, CPM, and your Congressional Representative have seen copies of this report. On the front there are these words typed in red: They knew — they buried this. Please save the world!

As an Engineer on the GFC team, I feel a very loyal tie to my boss and my company/country. I have mortgage, and family to feed. It is likely if I blow the whistle on this report, I will lose my job and my livelihood. I'm not even sure who wrote the study in the envelope or who actually sent it to me.

Utilizing my profession's code of ethics, what should be my first step?

Who should I talk to first?

should I go to the press?

should I go to your boss?

Should I react at all?

What professional ethics codes with international scope can I use to see the guidance given for dilemmas such as this.

In: Psychology

Part A The table below lists customer/car hires data. Each customer may hire cars from various...

Part A

The table below lists customer/car hires data. Each customer may hire cars from various outlets throughout Singapore. A car is registered at a particular outlet and can be hired out to a customer on a given date.

carReg

make

model

custNo

custName

hireDate

outletNo

outletLoc

M565 0GD

Ford

Escort

C100

Smith, J

14/5/18

01

Queenstown

M565 0GD

Ford

Escort

C201

Hen, P

15/5/18

01

Queenstown

N734 TPR

Nissan

Sunny

C100

Smith, J

16/5/18

01

Queenstown

M134 BRP

Ford

Escort

C313

Blatt, O

14/5/18

02

Tampines

M134 BRP

Ford

Escort

C100

Smith, J

20/5/18

02

Tampines

M611 0PQ

Nissan

Sunny

C295

Pen, T

20/5/18

02

Tampines

Instructions:

  1. The data in the table is susceptible to update anomalies. Provide examples of how insertion, deletion, and modification anomalies could occur on this table.
  2. Describe and illustrate the process of normalization by converting Table 1 to Third Normal Form (3NF) relations. Identify the primary and foreign keys in your 3NF relations.

Part B

The following tables form part of a database held in a Relational Database Management System for a printing company that handles printing jobs for book publishers:

Publisher                        (pubID, pubName, street, city, postcode, telNo, creditCode)

              BookJob                          (jobID, pubID, jobDate, description, jobType)

              PurchaseOrder               (jobID, poID, poDate)

              POItem                            (jobID, poID, itemID, quantity)

              Item                                  (itemID, description, onHand, price)

Where:

Publisher                          contains publisher details and pubID is the key.

BookJob                            contains details of the printing jobs (books or part books) and jobID is the key.

PurchaseOrder                 A printing job requires the use of materials, such as paper and ink, which are assigned to a job via purchase orders. This table contains details of the purchase orders for each job and the key is jobID/poID. Each printing job may have several purchase orders assigned to it.

POItem                              Each purchase order (PO) may contain several PO items. This table contains details of the PO items and jobID/poID/itemID form the key.

Item                                   contains details of the materials which appear in POItem, and the key is itemID.

Instructions:

Formulate the following queries using SQL:

(i)                         List all publishers in alphabetical order of name.

(ii)                        List all printing jobs for the publisher ‘Gold Press’.

(iii)                      List the names and phone numbers of all publisher who have a rush job (jobType = ‘R’).

(iv)                       List the dates of all the purchase orders for the publisher ‘PressMan’.

(v)                        How many publisher fall into each credit code category?

(vi)                       List all job type’s with at least three printing jobs.

(vii)                     List the average price of all items.

(viii) List all items with a price below the average price of an item.

In: Computer Science

In April 2019, Paul Marrapese, an independent security researcher from San Jose, California, has published research...

In April 2019, Paul Marrapese, an independent security researcher from San Jose, California, has published research warning that peer-to-peer software developed by Shenzhen Yunni Technology firm, that's used in millions of IoT devices around the world, has a vulnerability that could allow an attacker to eavesdrop on conversations or press household items into service as nodes in a botnet.

The software, called iLnkP2P, is designed to enable a user to connect to IoT devices from anywhere by using a smartphone app. The iLnkP2P functionality is built into a range of products from companies that include HiChip, TENVIS, SV3C, VStarcam, Wanscam, NEO Coolcam, Sricam, Eye Sight, and HVCAM.

What Marrapese found is that as many as 2 million devices, and possibly more, using iLnkP2P software for P2P communication do not have authentication or encryption controls built-in, meaning that an attacker could directly connect to a device and bypass the firewall. Marrapese discovered the iLinkP2P flaw after buying an inexpensive IoTconnected camera on Amazon.

"I found that I was able to connect to it externally without any sort of port forwarding, which both intrigued and concerned me," Marrapese told Information Security Media Group. "I found that the camera used P2P to achieve this, and started digging into how it worked. From there, I quickly learned how ubiquitous and dangerous it was."

While the flaws with the iLnkP2P peer-to-peer software apparently have not yet been exploited in the wild, Marrapses believes it's better for consumers to know now before an attacker decides to start taking advantage of this particular vulnerability.

"There have been plenty of stories in the past about IP cameras and baby monitors being hacked, but I believe iLnkP2P is a brand new vector not currently being exploited in the wild," Marrapese says. "With that being said, the biggest motivation behind this disclosure is to inform consumers before it's too late - because I believe it's only a matter of time." As part of his research, Marrapese says he attempted to contact not only Shenzhen Yunni Technology but also several of the IoT manufacturers that use the company's P2P software. As of Monday, even after publishing results, he had not heard back from anyone.

Users of IoT devices that make use of the iLnkP2P software scan a barcode or copy a sixdigit number that is included in the product. From there, the owner can access the device from a smartphone app.

It's through these unique identifier numbers that Marrapese was able to discover that each device manufacturer used a specific alphabetic prefix to identify their particular product. For instance, HiChip uses "FFFF" as a prefix for the identification number for its devices. Once Marrapese was able to identify these devices through the unique number systems, he created several proof-of-concept attacks that took advantage of the flaws in the software.

a) In this case study, it is mentioned that vulnerable IoT devices can service as nodes in a botnet. Explain the working mechanism of a Botnet. Discuss any two attacks carried out by a botnet.

b) Report the importance of security in IoT devices. How does encryption help improve security for these devices?

c) Discuss the importance of lightweight cryptography in IoT enabled low-power devices. List the potential lightweight cryptographic algorithms for low-power IoT devices.

In: Computer Science

IM GETTING A ERROR MESSAGE : if rentalCode == 'W' and averageMiles <= 900: mileCharge =...

IM GETTING A ERROR MESSAGE :

if rentalCode == 'W' and averageMiles <= 900:
mileCharge = weeksRented * 100.00
else:

Collect Customer Data - Part 2

  1. Collect Mileage information:

    Prompt: "Starting Odometer Reading:\n"

    Variable: odoStart = ?

    Prompt: "Ending Odometer Reading:\n"

    Variable: odoEnd = ?

    Add code to PRINT odoStart and odoEnd variables as well as the totalMiles to check your work.

    The following data will be used as input in the test:

    odoStart = 1234
    odoEnd = 2222
    

    Collect Customer Data - Part 2 - Feedback Link

    IF you would like some constructive feedback on your assignment before you submit for a grade, press the Help Me! button below.

    Help Me!

    Customer Data Check 2

    In your rental_car.py file, add code to print out the two new variables you have collected input for:
    odoStart
    odoEnd
    totalMiles

    1. Prompt the user to input the starting odometer reading (expect type int from the user)
    2. Prompt the user to input the ending odometer reading (expect type int from the user)
      1. Test your code.
      2. import sys
        '''
        Section 1: Collect customer input
        '''
        #Add customer input 1 here, rentalCode = ?
        rentalCode = input("(B)udget, (D)aily, or (W)eekly rental?\n")
        print (rentalCode)
        #Collect Customer Data - Part 2

        #4)Collect Mileage information:
        #a)   Prompt the user to input the starting odometer reading and store it as the variable odoStart

        #Prompt -->"Starting Odometer Reading:\n"
        # odoStart = ?
        odoStart = input('Starting Odometer Reading: ')
        #b)   Prompt the user to input the ending odometer reading and store it as the variable odoEnd

        #Prompt -->"Ending Odometer Reading:"
        # odoEnd = ?
        odoEnd = input('Ending Odometer Reading: ')
        #c) Calculate total miles
        totalMiles = int(odoEnd) - int(odoStart)
        #Print odoStart, odoEnd and totalMiles
        print (odoStart)
        print (odoEnd)
        print (totalMiles)

        # Calculate Charges 2

        ##   Calculate the mileage charge and store it as
        # the variable mileCharge:

        #a)   Code 'B' (budget) mileage charge: $0.25 for each mile driven
        if rentalCode == "B":
        mileCharge = totalMiles * 0.25
        #b)   Code 'D' (daily) mileage charge: no charge if the average
        # number of miles driven per day is 100 miles or less;
        # i)   Calculate the averageDayMiles (totalMiles/rentalPeriod)
        elif rentalCode == "D":
        averageDayMiles = totalMiles/rentalPeriod
        if averageDayMiles <= 100:
        extraMiles == 0
        # ii)   If averageDayMiles is above the 100 mile per day
        # limit:
        # (1)   calculate extraMiles (averageDayMiles - 100)
        if totalMiles >= 100 and rentalCode == 'D':
        # (2)   mileCharge is the charge for extraMiles,
        mileCharge = totalMiles * int(rentalPeriod) *0.25   
        #c)   Code 'W' (weekly) mileage charge: no charge if the
        # average number of miles driven per week is
        # 900 miles or less;
        if rentalCode == 'W' and averageMiles <= 900:
        mileCharge = weeksRented * 100.00
        else:
        mileCharge = 0
        # i)   Calculate the averageWeekMiles (totalMiles/ rentalPeriod)
        # ii)   mileCharge is $100.00 per week if the average number of miles driven per week exceeds 900 miles
        if rentalCode == 'W' and averageMiles >= 900:
        mileCharge = weeksRented * 100.00
        else:
        print('Charges : ${}'.format(mileCharge))

In: Computer Science