Question
I have been working on this assignment and I want the code for what I have gotten so far. I want to be able to
I have been working on this assignment and I want the code for what I have gotten so far. I want to be able to output and convert miles into kilometers but I do not know why it is not working. If someone can please fix this and explain why this isn't working that would be helpful. Also underneath this code is the link to the actual assignment I am working on. The entire thing is in Irvine32 MASM. I would highly prefer to keep the way my current formatting looks.
INCLUDE Irvine32.inc .data FIVE DWORD 5 NINE DWORD 9 CEL32 DWORD 32 MILES DWORD ? KILOMETERS DWORD ? KPM DWORD 1.60934
KEL32FP real4 273.15
program BYTE " Distance & Temperature Unit Conversion",0 author BYTE " Programmed by First Last",0 prompt1 BYTE " Hi, what's your name? ",0 userName BYTE 21 DUP (0) greeting BYTE " Hello, ",0 prompt2 BYTE " Enter the distance in miles that you want to convert in kilometers: ",0 miles BYTE "Miles: ",0 kilometers BYTE " = Kilometers: ",0 display1 BYTE " Miles in kilometers = ",0 prompt3 BYTE " Now enter the temperature in Fahrenheit that you want to convert in Celsius: ",0 display2 BYTE " Degrees Celcius = ",0 goodbye1 BYTE " Results certified by First Last",0 goodbye2 BYTE " Goodbye, ",0
.code main PROC
;Program name mov edx,OFFSET program call WriteString call Crlf ;Author name mov edx,OFFSET author call WriteString call Crlf call Crlf ;User's name mov edx,OFFSET prompt1 call WriteString mov edx,OFFSET userName mov ecx,SIZEOF userName call ReadString ;Greeting mov edx,OFFSET greeting call WriteString mov edx,OFFSET userName call WriteString call Crlf ;Asking Prompt2 mov edx, OFFSET prompt2 call WriteString call ReadFloat, MILES call Crlf ;Conversion from Miles to Kilometers fld MILES fld1 fld qword ptr [KPM] fmul fstp KILOMETERS mov edx, OFFSET miles call WriteString call WriteInt, miles, 0
mov edx, OFFSET kilometers call WriteString call WriteFloat, kilometers, 3 ;Asking Prompt3 mov edx, OFFSET prompt3 call WriteString call Crlf call ReadFloat call Crlf ;Conversion from F to C fild CEL32 fsub fild FIVE fild NINE fdiv fmul mov edx, OFFSET display2 call WriteString call WriteFloat call Crlf ;Farewell Statement call Crlf call Crlf mov edx,OFFSET goodbye1 call WriteString call Crlf mov edx,OFFSET goodbye2 call WriteString mov edx,OFFSET userName call WriteString call Crlf call Crlf
exit main ENDP END main
Problem Definition: Write a program to convert miles to kilometers and Fahrenheit to Celcious. - Display the program title and programmer's name. Then get the user's name and greet the user. - Prompt the user to enter the distance in miles that they want to convert and then prompt them to enter the temperature that they want to convert in Fahrenheit. - Convert and display the user values and the converted values. - Display a parting message that includes the user's name and terminate the program. Requirements: 1) The programmer's name and the user's name must appear in the output. 2) The main procedure must be modularized into at least the following sections (using labels): a. introduction b. getUserData c. convertToKM d. convertToCelcious e. displayConvertedData f. farewell 3) The program must be fully documented. This includes a complete header block for identification, description, etc., and a comment outline to explain each section of code. Notes: 1) For the conversions assume that 1 mile =1.60934 kilometers, and the formula to convert the temperature from Fahrenheit to calcious is C=5/9(F32) Example (user input in italics): Distance \& Temperature Unit Conversion Programmed by Leonardo Pisano Hi, what's your name? Joanne Hello, Joanne Enter the distance in miles that you want to convert in kilometers: 50 Now enter the temperature in Fahrenheit that you want to convert in Celsius: 14 The conversion of 50 miles in kilometers is: +8.0467000E+001 The conversion of 14 degrees Fahrenheit in Celsius is: 9.9999000E+000 Results certified by Leonardo Pisano. Goodbye, Joanne. Extra-credit options (original definition must be fulfilled): 1. Implement more conversions. 2. Do something incredible. To ensure you receive credit for any extra credit options you did, you must add one print statement to your program output PER EXTRA CREDIT which describes the extra credit you chose to work on. You will not receive extra credit points unless you do this. The statement must be formatted as follows... --Program Intro-- EC : DESCRIPTION --Program prompts, etc
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started