Hello! I would greatly appreciate help with this!
Write a MIPS assembly language program that reads in how many days a customer will be staying in a hotel, and also reads in how many number of beds per room were needed, compute its price based on the following rules:
If a customer is staying in a room with one bed for less than 8
days,
then the total price will be $90 * the number of days to stay.
If a customer is staying in a room with one bed for 8 days or
more, then they will get the discount of $60,
and the total price will be $90 * the number of days to stay -
$60.
If a customer is staying in a room with two beds for less than 8
days,
then the total price will be $150 * the number of days to stay.
If a customer is staying in a room with two beds for 8 days or
more, then they will get the discount of $90,
and the total price will be $150 * the number of days to stay -
$90.
For any other case, the price should be $0.
If a customer enters a number of beds per room to be any number other than 1 or 2, then it should print out the message "Sorry, we have only one or two beds per room.\n", and exit the program without computing its price. If a customer enters 1 or 2 as a number of beds per room, then the program should proceed to compute its total price, and print out the message using the format of "Your total price: XXX dollars for YYY days\n". where XXX is the total price and YYY is the number of days to stay.
Program Screenshots:






Sample Output:
Run1:
1bed less than 8days:

Run2:
2bed lessthan 8 days:

Run3:
1bed 8days or more:

Run4:
2bed more than 8days:

Run5:
For invalid case neithe 1bed not 2bed

Run6:
All other cases:

Code to be Copied:
printrooms.asm
#data section
.data
#prompt for days
daysPrompt: .asciiz "Enter number of days of customer
staying in hotel: "
#prompt for beds
bedsPrompt: .asciiz "Enter number of beds per room
were needed: "
#prompt for error msg
incorrect: .asciiz "Sorry, we have only one or two
beds per room.\n"
#prompt for price msg
pricemsg: .asciiz "Your total price: "
#prompt for all othercases
allothercases: .asciiz "Your total price is $"
#prompt for print dollars msg
dollarsmsg: .asciiz " dollars for "
#prompt for days msg
daysmsg: .asciiz " days\n"
#text section
.text
#add the discount values in the registers
addi $s3, $zero, 90
addi $s4, $zero, 60
addi $s5, $zero, 150
addi $0, $zero, 0
#print the prompt msg
for input days
li $v0, 4
la $a0, daysPrompt
syscall
#read the input
days
li $v0, 5
syscall
move $s0, $v0
#print the prompt msg
for input beds per room
li $v0, 4
la $a0, bedsPrompt
syscall
#read the input
beds
li $v0, 5
syscall
move $s1, $v0
#if the input days is
negative, Call the label
#printzero
ble
$s0,$0,printzero
#check whether input
beds is 2
beq $s1, 2,
twoBeds
#check whether input
beds is 1
beq $s1, 1, oneBed
#load the value in
$a0
li $v0, 4
#call the label
incorrect
la $a0, incorrect
syscall
#if input is invalid
exit from the program
#with out print the
total price
li $v0, 10
syscall
#if a customer is staying in a room with one
bed
#for less than 8 days,
oneBed:
#check for 1 bed for
less than 8 days
bgt $s0, 7,
onebedgreatereight
blt $s0, 8,
onebedlessthaneight
#then the total price will be $90 * the number
of days to stay.
onebedlessthaneight:
mul $s2, $s0, $s3
j output
#check for 2beds with 8days or more
#the total price will be $90 * the number of
days to stay - $60.
onebedgreatereight:
mul $s2, $s0, $s3
sub $s2, $s2, $s4
j output
#If a customer is staying in a room with two
beds for less than 8 days,
twoBeds:
bgt $s0, 7,
twobedgreaterethaneight
blt $s0, 8,
twobedlessthaneight
#then the total price will be $150 * the number
of days to stay.
twobedlessthaneight:
mul $s2, $s0, $s5
j output
# total price will be $150 * the number of
days to stay - $90.
twobedgreaterethaneight:
mul $s2, $s0, $s5
sub $s2, $s2, $s3
j output
#implement ouptut function
output:
#print label
li $v0, 4
la $a0, pricemsg
syscall
#print the value
li $v0, 1
move $a0, $s2
syscall
#print the
label
li $v0, 4
la $a0, dollarsmsg
syscall
#print the value
li $v0, 1
move $a0, $s0
syscall
#print label
li $v0, 4
la $a0, daysmsg
syscall
#exit from the
program
li $v0, 10
syscall
#for all othercase print $0
printzero:
li $v0, 4
la $a0,
allothercases
syscall
#print 0 dollars
li $v0, 1
move $a0, $s2
syscall
#exit from the
program
li $v0, 10
syscall
Hello! I would greatly appreciate help with this! Write a MIPS assembly language program that reads...
Q-1: Write a program in Assembly language using MIPS instruction set that reads 15 integer numbers from user and stores all the numbers in the array intArray. Now, read another integer number N from the user, find the total number of array elements that are greater or equal to the number N, and the total number of array elements that are lower than the number N You must have two procedures: i. ReadIntegerArray: this procedure should read integer array elements...
MIPS - assembly language Task I (1 mark): Write a program to calculate the nth Fibonacci number based on an iterative approach where value n is read from the keyboard and stored in your main program that is calling fib. The main program reads number ‘n’ -- restrict range of ‘n’ to 2-50, and display an error message if this condition is not satisfied. The main program calls fib with parameter passing. Procedure fib should return the calculated...
Exercise 1: Write a program which repeatedly reads numbers until the user enters "done". Once "done" is entered, print out the total, count, and average of the numbers. If the user enters anything other than a number, detect their mistake using try and except and print an error message and skip to the next number. Enter a number: 4 Enter a number: 5 Enter a number: bad data Invalid input Enter a number: 7 Enter a number: done 16 3...
I'm quite stuck with this C++ question, I would greatly appreciate the help! Many companies use telephone number like 888- COM - CAST so the number is easier for their customer to remember. On a standard telephone, the alphabetic letters are mapped to numbers in the following fashion. A, B, and C = 2 D, E, and F = 3 G, H, and I = 4 J , K , and L = 5 M, N, and O = 6...
2. Write an 80x86 assembly language program that reads byte size signed integers from memory and counts the number of zeros. Store this count in memory. End when you get a negative number. (20pts) For example: nums DB 4, 0, 0, 12, 6, 8, 0, 4, -1 count DB 0 after executing the procedure count should be 3 count DB 3.
1. Write a program in Assembly language using MIPS instruction set that reads two integer numbers from the user named as start and end number and finds out all the prime numbers between start and end (including start and end). Your program should do the validation of both the numbers as follows: i. start number must be smaller or equal to the end number. ii. Both numbers must be positive. iii. The maximum value for the end number is 10000...
hello. i need help with number 2
ONLY
1. Use if statements to write a Java program that inputs a single letter and prints out the corresponding digit on the telephone. The letters and digits on a telephone are grouped this way 2=ABC 3 = DEF 4 GHI 5 JKL 6 - MNO 7 - PRS 8 - TUV 9-WXY No digit corresponds to either Qor Z. For these 2 letters your program should print a message indicating that they...
Lab/HW 3 Write a program that reads in the following data, all entered on one line with at least one space separating them: a) an integer representing a month b) an integer representing the day of the month c) an integer representing a year 1. Check that the month is between 1 and 12. If it’s not print an error message. 2. Day cannot be 0 or less nor can it be more than 31 for all months. Print...
MIPS ASSEMBLY PROGRAM: PLEASE Write in MIPS Assembly language. Take strings as input and calculate and print a simple checksum for each string. Make your string long enough to hold 50 characters. Don't forget to leave space for the null byte. Our checksum algorithm will produce a value which you can print with the syscall for printing a character. Stop reading strings when the user enters ".". The syscall to read a string (sycall code 8) adds a newline to...
2. Write a program to prepare email address with name of person, email ID. This program should collect number of persons with their details menstion in the above. Finally, print all the registerd preson with their details and also print selected particular person's emails. 1. Write a program to prepare departmental store records with item name, number of items. This program should collect number of items with its details menstion in the above. Finally, print all the registerd items with...