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...

  • In python Simply write the Euclid algorithm in a form that takes two numbers from input...

    In python Simply write the Euclid algorithm in a form that takes two numbers from input and prints the gcd. The code does not need to check for valid input. It must work for any pair of positive integers. Create a separate program that uses the python timeit module to provide test run-times for your code. Provide at-least 5 sample runs. Create a third file that implements another algorithm to find the gcd. Provide a program that uses the timeit...

  • 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...

  • mick and rose Students do not like programming and they do not have a subject so...

    mick and rose Students do not like programming and they do not have a subject so they decide to play a simple game, where rose hands a group of negative and positive numbers, so rose converts negative numbers to zeros and positive to ones Then the result is converted to a decimal number, for example 5 8-9 0 -5 7 10101, and then we convert the result 10101 = 21 and the output is decimal using python or c++ write...

  • PYTHON Write a program to enter a valid variable till the user wants to end. The...

    PYTHON Write a program to enter a valid variable till the user wants to end. The program should display the count of positive, negative, zeros and letters (upper and lower case)/symbols (error handling) entered. Based on the problem, you need to design an algorithm as follows: 1. Get the user input until “n” is entered 2. Add to the positive if it is greater than zero 3. Add to the negative if it is less than zero 4. Add 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 {...

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