Question: Write a program in MIPS Assembly that prints the first 10 multiples of a given number and the sum of those multiples (As shown below)
Write a program in MIPS Assembly that prints the first 10 multiples of a given number and the sum of those multiples (As shown below)
Example Program Run: (User entry is shown in Bold)
Please enter an integer value: 3
3, 6, 9, 12, 15, 18, 21, 24, 27, 30
Total: 165 **Java Code to translate into MIPS Assembly**
// Program Code import java.util.Scanner; public class Multiples { public static void main(String[] args) { Scanner stdin = new Scanner(System.in); int base, multiples, total = 0; System.out.println("Enter a positive number and I will display " + "the first 10 multiples and the sum of those " + "multiples"); base = stdin.nextInt(); if (base > 0) { multiples = base; for (int i = 0; i < 10; i++) { System.out.print(multiples + " "); total += multiples; multiples += base; } System.out.println(" Total: " + total); } else { System.out.println("Invalid Input. GIGO!!!!"); } } } ____________________________________________________________ Test the code with both an invalid and number Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
