Você está na página 1de 4

College of Computing Education

3rd Floor, DPT Building


Matina Campus, Davao City
Telefax: (082)
Phone No.: (082)300-5456/305-0647 Local 116

[ Laboratory No. 1.3: E-Car Battery Monitoring]


Objectives:
1. To know the basics about Python Programming and its concepts
2. To create a program that takes input from the user and display necessary information as required

Materials:
1. PC or Laptop
2. Python Package Development Kit
3. Pycharm or any IDE

Background

Instructions:

1. Create class ECar[Surname]


2. Problem Scenario
Electronic vehicles are becoming rampant nowadays because of its environment friendly benefits.
One problem they seem to observe for the owners is the monitoring of how much exact
percentage of battery charge will the owner be needing per destination. The consumption is based
on kilograms’ load and distance travelled. You seemed to be very optimistic on helping them, thus
you are very eager to develop a program that foresee and monitor battery consumptions of a car
or vehicle.

Each km travel on a normal load (0) is thrice the distance to be consumed or should be reduced
from your vehicle’s battery charge. While twice the mass (kg) of the load per km travelled
diminishing value. How much amount of battery charge, allowable distance and kg needed for
each vehicle for each destination?

3. Input

Input consist 1 integer percentage for car battery charge and 3 values float values: distance
travelled in km, load weight in kg, and vehicle’s capacity or Gross vehicle weight rating(GVWR) in
pounds (lbs) where 1 kg= 2.20462262

4. Constraints
0 ≤ battery charge(percentage) ≤100
3,000.00 ≤ GVWR (lbs) ≤10,000.00
0.1 ≤ Distance (km) ≤ ∞
0 ≤ load weight (kg) ≤ GVRW max limits

5. Output

Your program should output the battery charge before the travel, GVRW, distance, load weight,
and battery charge after the travel.

6. Source Codes

IT5/L Martzel P. Baste|Page 1


College of Computing Education
3rd Floor, DPT Building
Matina Campus, Davao City
Telefax: (082)
Phone No.: (082)300-5456/305-0647 Local 116

percentage=int(input("Battery charge(percentage): "))


distance=float(input("Distance travelled(km): "))
mass=float(input("Load weight(kg): "))
capacity=float(input("vehicle capacity(lbs): "))

massPound = mass*2.20462262

if percentage < 0 or percentage > 100:


print("Invalid input")
elif capacity < 3000 or capacity > 10000:
print("Overload/Underload!!")
elif distance < 0.1:
print("Invalid distance!")
elif massPound < 0:
print("Invalid!!")
elif massPound > capacity:
print("Too Heavy!")
else:
if mass == 0:
battCharge = distance * 3
finalPercentage= percentage-battCharge
print(finalPercentage)
else:
battCharge = distance * 3
finalPercentage = percentage - ((mass/2)+battCharge)
print("Battery charge before travel",percentage,"%")
print("GVWR: ",capacity)
print("Distance(km): ", distance)
print("Load Weight(kg): ",mass)
print("Battery charge after travel",finalPercentage,"%")

7. Sample Input/Output
IT5/L Martzel P. Baste|Page 2
College of Computing Education
3rd Floor, DPT Building
Matina Campus, Davao City
Telefax: (082)
Phone No.: (082)300-5456/305-0647 Local 116

NOTE: Provide a screenshot and describe your observation for each action you performed based on the
item below:

 Input any value for battery charge, gvwr, distance and load between the constraints

If you input any value between the constraints the program will run smoothly and will compute the Battery
consumption after the travel.

 Input any battery charge, gvwr, distance and load value NOT between the constraints

If you input values which is NOT between the constraints the the program will display “Invalid Input”
because there is an if statement in the program that will only run if it satisfy its condition.

 Input any value for load more than its gvwr

If you input value for load which is more than its capacity it will also display a msg “Too Heavy!” because
the load you input is more than or heavier than its capacity or GVWR.

IT5/L Martzel P. Baste|Page 3


College of Computing Education
3rd Floor, DPT Building
Matina Campus, Davao City
Telefax: (082)
Phone No.: (082)300-5456/305-0647 Local 116

 Input less battery charge with much more required distance and load

If you input a value of distance which is too much to the remaining battery than your e-car can run. The
program will still run but it will give you a negative value of Battery charge after travel.

8. Submit your file with filename convention: ECar[Surname]

Rules:

1. Each laboratory activity has time limit of 1:30 minutes and is due on the
day depending on the level of difficulty or constraints.

2. Each activity will only last every after 3 days and has deduction of 10
points every day from the day it was given.

IT5/L Martzel P. Baste|Page 4

Você também pode gostar