There is a standard reverser that will work for this:
void printbackwards(string s)
{
reverse(s.begin(), s.end());
cout << s;
}
Answer:
Python Code
Explanation:
total = 0.0
change = 0.0
itemone = float(input("Enter the first price: "))
itemtwo = float(input("Enter the second price: "))
itemthree = float(input("Enter the third price: "))
total = itemone + itemtwo + itemthree
print("Total:", total)
cash = float(input("Cash given: "))
change = total - cash
print("Your change:", change)
Answer:
def str_analysis(s):
if s.isdigit():
s = int(s)
if s > 99:
message = str(s) + " is a pretty big number"
else:
message = str(s) + " is a smaller number than expected"
elif s.isalpha():
message = s + " is all alphabetical characters!"
else:
message = "There are multiple character types"
return message;
s = input("enter word or integer: ")
while s != "":
print(str_analysis(s))
s = input("enter word or integer: ")
Explanation:
- Check if the string is digit, alphabetical, or mixed inside the function
- Ask the user for the input
- Call and print the result of the <em>str_analysis</em> function inside the while loop
- Keep asking for the input until the given string is empty