First one I think RAM and second one is Barcode reader
Answer:
def cost(quantity, unit_price, taxable):
if taxable == "Yes":
total = (quantity * unit_price) + (quantity * unit_price * 0.07)
elif taxable == "No":
total = quantity * unit_price
return total
q = int(input("Enter the quantity: "))
p = float(input("Enter the unit price: "))
t = input("Is %7 tax applicable? (Yes/No): ")
print(str("$" + str(cost(q, p, t))))
Explanation:
- Create a function called cost that takes three parameters, quantity, unit price, and taxable
- If the tax is applicable, calculate the total with tax. Otherwise, do not add the tax.
- Return the total
- Ask the user for the inputs
- Call the function with given inputs and print the result
When you are charged with DUI or Driving under influence, there are many possible consequences for such crime.
One, your insurance company might require you to increase the price or upgrade your subscription to premium. Or, worst case is they will terminate your subscription immediately upon knowing.
Answer:
import java.io.*;
public class Main
{
public static void main(String[] args) throws IOException {
BufferedReader bufferObject=new BufferedReader(new InputStreamReader(System.in));
String stringObject=bufferObject.readLine();
while(!stringObject.equals("99:99AM")){
System.out.println(convertedTime(stringObject));
stringObject=bufferObject.readLine();
}
}
public static String convertedTime(String stringObject){
String s=stringObject.substring(stringObject.length()-2);
String[] timeObject=stringObject.substring(0,5).split(":");
if(s.equals("AM")){
if(timeObject[0].equals("12")) return "00"+timeObject[1];
else return timeObject[0]+timeObject[1];
}
else{
if(timeObject[0].equals("12")) return "12"+timeObject[1];
else{
int hours=Integer.valueOf(timeObject[0]);
timeObject[0]=String.valueOf(12+hours);
return timeObject[0]+timeObject[1];
}
}
}
}
Explanation:
- Inside the main method run a while loop until stringObject is not equal to the string "99:99AM".
- Call the convertedTime method and display the results.
- Use the same hours and minutes except for 12th hour If the time is in AM.
- Use "00" instead of 12, if it is 12th hour.
- Add hours to 12, if the time is in PM and don't change anything in case of 12.