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 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...
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...
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...
(USING THE PROGRAM MARS) Using the MemoryAccess program we wrote in class as a starting point, write a program called LoadStore # Title : Memory access.asm #Desc: Practice initially memory, #in val1 = 0x0a; #int val2 = 0x0b; #int result; #string resultstring = " final answer : "; #string returnchar = "\n"; #void main() { # result = val1 + val2; # cout<<< resultstring << returnchar; #} .data val1: .word 0x0a #store 0xa into variable val1 val2: .word 0x0b #store...
Write a C program that does the following: Displays a menu (similar to what you see in a Bank ATM machine) that prompts the user to enter a single character S or D or Q and then prints a shape of Square,Diamond (with selected height and selected symbol), or Quits if user entered Q.Apart from these 2 other shapes, add a new shape of your choice for any related character. Program then prompts the user to enter a number and...