1)
#switchCase.mar
def main() :: io Num:
var age :: Num
# declaring variable age
print_string("Please enter age : ")
age = get_char() :: io Num # taking input from
user for value of age
switch age:
case 0
:
# case 0 .. 3 are for under 3
print_string("free\n")
case 1 :
print_string("free\n")
case 2 :
print_string("free\n")
case 3
:
# case 3 .. 12 are for age [3 to 12]
print_string("$5\n")
case 4 :
print_string("$5\n")
case 5 :
print_string("$5\n")
case 6 :
print_string("$5\n")
case 7 :
print_string("$5\n")
case 8 :
print_string("$5\n")
case 9 :
print_string("$5\n")
case 10 :
print_string("$5\n")
case 11 :
print_string("$5\n")
case 12 :
print_string("$5\n")
case
21:
# case 21 .. 55 are for age [21 to 55]
print_string("$15\n")
case 22:
print_string("$15\n")
case 23:
print_string("$15\n")
case 24:
print_string("$15\n")
case 25:
print_string("$15\n")
case 26:
print_string("$15\n")
case 27:
print_string("$15\n")
case 28:
print_string("$15\n")
case 29:
print_string("$15\n")
case 30:
print_string("$15\n")
case 31:
print_string("$15\n")
case 32:
print_string("$15\n")
case 33:
print_string("$15\n")
case 34:
print_string("$15\n")
case 35:
print_string("$15\n")
case 36:
print_string("$15\n")
case 37:
print_string("$15\n")
case 38:
print_string("$15\n")
case 39:
print_string("$15\n")
case 40:
print_string("$15\n")
case 41:
print_string("$15\n")
case 42:
print_string("$15\n")
case 43:
print_string("$15\n")
case 44:
print_string("$15\n")
case 45:
print_string("$15\n")
case 46:
print_string("$15\n")
case 47:
print_string("$15\n")
case 48:
print_string("$15\n")
case 49:
print_string("$15\n")
case 50:
print_string("$15\n")
case 51:
print_string("$15\n")
case 52:
print_string("$15\n")
case 53:
print_string("$15\n")
case 54:
print_string("$15\n")
case 55:
print_string("$15\n")
case
_:
# this is the default case for age [over 55 or (3-12)]
print_string("$10\n")
return 0
Command line output :
$ mars switchCase.mar
Please enter age : 15
$10
$ mars switchCase.mar
Please enter age : 72
$10
$ mars switchCase.mar
Please enter age : 25
$15
2)
#ifElse.mar
def main() :: io Num:
var age :: Num #
declaring variable age
print_string("Please enter age : ")
age = get_char() :: io Num # taking input from user for value of age
if age >
55: # if age is over
55
print_string("$10\n")
elif age >= 21: # if
age is between [21,55]
print_string("$15\n")
elif age >= 13: # if
age is between [13,20]
print_string("$10\n")
elif age >= 3:
# if age is between [3,12]
print_string("$5\n")
elif age > 0 :
# if age is under 3
print_string("free\n")
return 0
Command line output :
$ mars ifElse.mar
Please enter age : 2
free
$ mars ifElse.mar
Please enter age : 10
$5
MARS 1. The controller of the cinema need create an admission charge program. Write the program...
1. Write a program that takes a number as input and check whether the number is positive, negative or zero. 2. Write a C++ program that prompts the user to enter a number and checks whether the entered number is even or odd. 3. Using switch-case statement write a C++ program that prompts the user to enter 1, 2 or 3 and display "Red" if selection is 1, "Yellow" if selection is 2, or "Green" if selection is 3. 4. Write...
Hi I need help doing this problem *The program must re-prompt as long as invalid input is inserted Implement a program that manages shapes. Implement a class named Shape with a virtual function area()which returns the double value. Implement three derived classes named Diamond, Oval, and Pentagon. Declare necessary properties in each including getter and setter function and a constructor that sets the values of these properties. Override the area() function in each by calculating the area using the defined...
Question 1 - while .. else loop Write a Python program to create the multiplication table (from 1 to 12) of a number that is given by the user. Example: User keyed in number 5 Output: Multiplication Table for 5 1 x 5 = 5 2 x 5 = 10 . . . 10 x 5 = 50 11 x 5 = 55 12 x 5 = 60
Write a program that prompts for a sentence and calculates the number of uppercase letters, lowercase letters, digits, and punctuation. Output the results neatly formatted and labeled in columns. how I can make this program in a more simple way. # get user input user_string = input("Enter a sentence: ") # create and initialize variables upper_case = 0 lower_case = 0 digits = 0 spaces = 0 punctuations = 0 x = len(user_string) #loop conditions and increment for i in...
Write a python program using Object Oriented and do the following: 1. create class "cat" with the following properties: name, age (create constructor method: def __init__) 2. create class "adopter" with the following properties: name, phone 3. create class "transaction" with these properties: adopter, cat (above objects) cat1 = "puffy, 2" adopter1 = "Joe, 123" Test your program: Joe adopts puffy. Print: "Per Transaction 1 <joe> has adopted <puffy>" this can only be done with object oriented programming, no way...
I need to create a Tic Tac Toe program in C++. These are the requirements Write a program that allows the computer to play TicTacToe against a human player or allow two human players to play one another. Implement the following conditions: The player that wins the current game goes first in the next round, and their symbol is X. The other player will be O. Keep track of the number of games played, wins, and draws for each player....
I need to write a java program call atm machine. Simulate An Atm Machine. create 10 accounts in an array with id,…,9 and an initial balance of $100. The Systems Prompts the user to enter an id. If the id is entered incorrectly it will ask the user to enter a correct id. Once an id is accepted, the main menu is displayed as shown in the sample run. You can choice 1 for viewing the current balance, 2 for...
In this assignment, you will develop a C++ program which calculates a shipping charge and determines the “type of trip” for a freight shipping company. Ask the user to enter the distance a package is to be shipped, and use a menu and a switch statement to determine the rate based on the package’s weight. Then display the shipping charge and using the table in #7 below, display the type of trip. Below is the chart to use to calculate...
Write a MARIE program to implement one round of rock paper scissors game. Your program should represent the three moves ‘rock’, ‘paper’ and ‘scissors’ with numbers 1, 2 and 3 respectively. When the program is run, there should be two input prompts, one after the other, to ask for player 1’s and player 2’s moves (a number 1, 2 or 3). Then the program would compare both numbers and apply the following rules to work out the winner. Paper beats...