Question

LogisimTinyCPU Programming Input A as a signed number, at any cell you like If A is...

LogisimTinyCPU Programming

  • Input A as a signed number, at any cell you like
  • If A is positive or zero, display decimal 1
  • If A is negative, display -1 in decimal
  • Add STOP to the end of the program (jmp $)

Provide the following

  1. Algorithm
  2. Memory Map
  3. Flow Chart
  4. Code
  5. Compile
  6. Run
0 0
Add a comment Improve this question Transcribed image text
Answer #1

ANSWER :

  • Given question is related to Decision making:

    Decision making is nothing but if a given condition is satisfied --> execute some block of code if not satisfies then some other block of code has to get executed.

    similarly

    switch case is also a decision making statement generally available in c language.

    Pseudocode

    1)Take input A

    2)if A>5

    2.1) display 1

    2.2)goto step 4

    3) if A<=5

    3.1)display -1

    3.2)goto step 5

    4)EXIT

    FLOWCHART

    Take input A No If A>5 Display -1 Yes Display 1 STOP

    Main.java

    import java.util.Scanner;

    public class Main{

    public static void main(String []args){
    Scanner sc=new Scanner(System.in);
    int A=sc.nextInt();
      
    if(A>5)
    System.out.println(1);
    else
    System.out.println(-1);
    }
    }

    Explaination:

    • scanner class is a class to read data from the input buffer in java.
    • nextInt is a method in scanner class that will read integers from console
    • System.out.print() will display output on output console.
    • We read integer into int type variable A

    if A>5 we prints 1

    else block is executed if a<=5

    OUTPUT

    Run Debug Stop Share Save {} Be Main.java i import java.util.Scanner; 2 3. public class Main{ 4 5 public static void main(StrMain.java 1 import java.util.Scanner; 2 3. public class Main{ 4 5 public static void main(String []args) { 6 Scanner sc=new S

Add a comment
Know the answer?
Add Answer to:
LogisimTinyCPU Programming Input A as a signed number, at any cell you like If A is...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • guys can you please help me to to write a pseudo code for this program and...

    guys can you please help me to to write a pseudo code for this program and write the code of the program in visual studio in.cpp. compile the program and run and take screenshot of the output and upload it. please help is really appreciated. UTF-8"CPP Instruction SU2019 LA X 119SU-COSC-1436- C Get Homework Help With Che X Facebook -1.amazonaws.com/blackboard.learn.xythos.prod/584b1d8497c84/98796290? response-content-dis 100% School of Engineering and Technology COSC1436-LAB1 Note: in the instruction of the lab change "yourLastName" to your last...

  • Write a program in MIPS assembly language that implements the DESCENDING bubble sort algorithm to sort a variable-sized array of signed 32-bit integers

    Write a program in MIPS assembly language that implements the DESCENDING bubble sort algorithm to sort a variable-sized array of signed 32-bit integers (words)that are read from the console. Be reminded that in a descending sort, the integers are sorted from the largest to the smallest. A “special value” 99999 will beused to signify the end of the input sequence. This value is not to be considered part of the input data set. However, any value greater than 99999 that...

  • Java programming for ticket price calculator.  It should ask the user if they would like to process...

    Java programming for ticket price calculator.  It should ask the user if they would like to process another ticket order. They should indicate their selection with a Y or N. If they indicate yes, then it should repeat the entire program with the exception of the welcome screen. If they indicate no, it should show the final thank you message and end the program. If they indicate an invalid answer, it should display an error and re-prompt them for a Y...

  • Help with programming in C++ Phase 1 is complete, please help with phase 2. Thank you....

    Help with programming in C++ Phase 1 is complete, please help with phase 2. Thank you. Phase 1 You must design 3 algorithms, and provide both a flow chart and pseudo code for the algorithms.    Algorithm descriptions: Given an integer parameter named current_number and two constant global variables: const int MIN_NUMBER = 1; const int MAX_NUMBER = 8; Create an algorithm named forward, that will advance ONE value through a sequence of numbers 1, 2, 3 ... MAX_NUMBER. In...

  • CSIT 345 Lab 2 Process Programming Your lab requirement is to write program codes for 3.21 and sh...

    *Help Please with the code** CSIT 345 Lab 2 Process Programming Your lab requirement is to write program codes for 3.21 and shared memory program for producer and consumer as shown in the following. You can start with the code provided in the virtual machine in the virtual box you installed. The code can be found in /home/oscreader/osc9e-src/ch3 a. For 3.21, you can start with the newprocposix.c and modify the code to meet your requirement. Then type: gcc neypCOCROSİS.c to...

  • Create an algorithm to count the number of 1’s in a 32-bit number. Implement the program in a high level language like...

    Create an algorithm to count the number of 1’s in a 32-bit number. Implement the program in a high level language like C or Java. It does not need to run for me, but the code should be included in a text document called FirstnameLastnameHLA3.txt along with your assignment submission. Implement the program in MIPSzy Assembly language. Use the high level code as comments to the right of the Assembly code as the textbook does. If you write that MIPSzy...

  • Create another program that will prompt a user for input file. The user will choose from...

    Create another program that will prompt a user for input file. The user will choose from 4 choices: 1. Display all positive balance accounts. 2. Display all negative balance accounts. 3. Display all zero balance accounts. 4. End program. C PROGRAMMING my code so far #include<stdlib.h> #include<stdio.h> int main(void) { int request; int account; FILE *rptr; char name[20]; double balance; FILE *wptr;    int accountNumber;    if((wptr = fopen("clients.dat","w")) == NULL) { puts("File could not be opened"); } else {...

  • 3 Programming Question (45 points) 3.1 Instructions You need to write the code by yourself. Your...

    3 Programming Question (45 points) 3.1 Instructions You need to write the code by yourself. Your implementation must use C/C++ and your code must run on the Linux machine general.asu.edu. Please refer to the programming guide (available under the Assignments folder on Blackboard) for using the general.asu.edu server, as well as compiling and running C/C++ code under Linux For this question, you need to provide a Makefile that compiles your program to an executable named a3 that runs on the...

  • #1 To execute a correctly written program, you first need to _____.                 highlight the output...

    #1 To execute a correctly written program, you first need to _____.                 highlight the output commands in the code                 print the code for reference                 compile it to machine language                 compile it from machine language into the programming language of choice #2 Adding capabilities to working software is called the _____ phase.                 coding                 maintenance                 debugging                 brainstorming #3 A rectangle in a flowchart represents which of the following?                 One or more I/Os                ...

  • Programming Exercise 4.6 Use the strategy of the decimal to binary conversion and the bit shift...

    Programming Exercise 4.6 Use the strategy of the decimal to binary conversion and the bit shift left operation defined in Project 5 bits = input("Enter bit string: ") bits = bits[1:] + bits[0] print ("Result:", bits) to code a new encryption algorithm. The algorithm should Add 1 to each character’s numeric ASCII value. Convert it to a bit string. Shift the bits of this string one place to the left. A single-space character in the encrypted string separates the resulting...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT