1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
lesantik [10]
3 years ago
9

Topic: Pseudo-codes

Computers and Technology
1 answer:
Arisa [49]3 years ago
7 0

Answer:

//program_start

//variable_inicialization

books = 0

maps = 0

magazines = 0

//End variable_inicialization

//operation_selection_routine

display "Select operation: (I) for input item to stock, (O) for output items in stock

operation = read_keyboard_input

IF (operation = "I")

goto input_routine

ELSE IF (operation = "O")

goto output_routine

ELSE

display "Incorrect option, try again"

goto operation_selection_routine

ENDIF

//End operation_selection_routine

//input_routine

display "Insert item code to add to stock"

input_code = read_keyboard_input

IF (input_code >= 1000 & input_code < 2000)

IF (input_code NOT duplicated_in_stock)

 add_to_stock (input_code)

 books = books + 1

 display "Book added"

ELSE

 display "Item Code is already present in stock"

ENDIF

ELSE IF (input_code >= 2000 & input_code < 3000)

IF (input_code NOT duplicated_in_stock)

 add_to_stock (input_code)

 maps = maps + 1

 display "Map added"

ELSE

 display "Item Code is already present in stock"

ENDIF

ELSE IF (input_code >= 3000 & input_code < 4000)

IF (input_code NOT duplicated_in_stock)

 add_to_stock (input_code)

 magazines = magazines + 1

 display "Magazine added"

ELSE

 display "Item Code is already present in stock"

ENDIF

ELSE IF (input_code = 9999)

goto program_end

ELSE

display "Incorrect option, try again"

goto input_routine

ENDIF

goto operation_selection_routine

//End input_routine

//output_routine

display "Items in stock"

display "Number of books: " + books

display "Number of maps: " + maps

display "Number of magazines: " + magazines

goto operation_selection_routine

//End output_routine

//program_end

display "Terminating stock program"

stop_program

Explanation:

Pseudo code is a way to design an algorithm using normal words and terms, that are not specific to any programming language. It is easier to understand how the program works and once finished, can be translated to the desired programming language.

This algorithm uses 5 blocks of code:

*variable_inicialization, where item counters are initially set to zero.

*operation_selection_routine, where the program request user input to select if the user will add an item or show existing items in stock. If an incorrect option is given, it will repeat this same routine.

*input_routine, the program will request the four digit code to add, and will check if it is not already present (to avoid duplicated items), and if the item code belongs to a book, map or magazine, increasing the corresponding item counter. Also, if the code is 9999 it will go to the program_end routine, otherwise it will display an error message and request a new item code. After a valid item code it will return to the operation_selection_routine.

*output_routine, it will display on screen the number of items for each category. Then, returns to the operation_selection_routine.

*program_end, it will simply display a goodbye message and terminate the program.

You might be interested in
Which of the following actions would help people determine their interests?
lorasvet [3.4K]
That depends on what the actions are, and what their personality is like.
8 0
3 years ago
(Solved—15 Lines) In many jurisdictions a small deposit is added to drink containers to encourage people to recycle them. In one
andrezito [222]

Answer:

JAVA program is given below.

import java.util.Scanner;

public class Main

{

   //static variables declared and initialized as required

   static float deposit1 = 0.10f;

   static float deposit2 = 0.25f;

   static float refund1;

   static float refund2;

   static int num_one_lit;

   static int num_more;

public static void main(String[] args){

    Scanner sc = new Scanner(System.in);

 System.out.print("Enter the number of containers of 1 liter or less: ");

 num_one_lit = sc.nextInt();

 System.out.print("Enter the number of containers of more than 1 liter: ");

 num_more = sc.nextInt();

 //refund computed based on user input

 refund1 = num_one_lit*deposit1;

 refund2 = num_more*deposit2;

 //displaying refund

 System.out.printf("Total refund amount for containers of 1 liter or less is $%.2f %n", refund1);

 System.out.printf("Total refund amount for containers of more than 1 liter is $%.2f %n", refund2);

}

}

OUTPUT

Enter the number of containers of 1 liter or less: 5

Enter the number of containers of more than 1 liter: 2

Total refund amount for containers of 1 liter or less is $0.50  

Total refund amount for containers of more than 1 liter is $0.50

Explanation:

1. Variables are declared at class level hence declared as static.

2. Variables holding deposit also initialized with the given values.

3. User input is taken for the number of containers in both categories.

4. The total value of refund is computed using the given values and user entered values.

5. The total refund is displayed to the user for both categories.

6. To display two decimal places always, variables to hold deposit and refund are declared as float.

7. The keywords used for decimals are %.2f %n. The %.2f keyword indicates two decimal places to be displayed in float variable, %n indicates a numeric value is to be displayed.

8. The printf() method is used to display the formatted output for refund amount.

9. The keywords used to display the formatted output is derived from C language.

10. All the code is written inside class and execution begins from the main() method.

4 0
4 years ago
Does anyone know any nitro type hack??
alexgriva [62]

Answer:

yes nitro hack is where they time your hacking skills

5 0
4 years ago
Read 2 more answers
Why does Linux make use of tasklets (i.e., software interrupts) instead of executing all interrupt-related activity in the (hard
Eddi Din [679]

Answer:

Although some devices can be controlled using nothing but their I/O regions, most real devices are a bit more complicated than that. Devices have to deal with the external world, which often includes things such as spinning disks, moving tape, wires to distant places, and so on. Much has to be done in a time frame that is different from, and far slower than, that of the processor. Since it is almost always undesirable to have the processor wait on external events, there must be a way for a device to let the processor know when something has happened.

That way, of course, is interrupts. An interrupt is simply a signal that the hardware can send when it wants the processor's attention. Linux handles interrupts in much the same way that it handles signals in user space. For the most part, a driver need only register a handler for its device's interrupts, and handle them properly when they arrive. Of course, underneath that simple picture there is some complexity; in particular, interrupt handlers are somewhat limited in the actions they can perform as a result of how they are run.

5 0
3 years ago
In this chapter, you saw an example of how to write an algorithm that determines whether a number is even or odd. Write a progra
vagabundo [1.1K]

Answer:

// Program is written in Java Programming Language

// Comments are used for explanatory purpose

// Program starts here

public class RandomOddEve {

/** Main Method */

public static void main(String[] args) {

int[] nums = new int[100]; // Declare an array of 100 integers

// Store the counts of 100 random numbers

for (int i = 1; i <= 100; i++) {

nums[(int)(Math.random() * 10)]++;

}

int odd = 0, even = 0; // declare even and odd variables to 0, respectively

// Both variables will serve a counters

// Check for odd and even numbers

for(int I = 0; I<100; I++)

{

if (nums[I]%2 == 0) {// Even number.

even++;

}

else // Odd number.

{

odd++;

}

}

//.Print Results

System.out.print("Odd number = "+odd);

System.out.print("Even number = "+even);

}

8 0
4 years ago
Read 2 more answers
Other questions:
  • What area contains the command used to customize the print options in microsoft excel?
    9·1 answer
  • Suppose we have an arrayAofnprofessors; each teacher has two characteristics: difficulty (a numberin the range [0,10], where a h
    7·1 answer
  • This is not homework but how do you fix this I’ve tried everything
    9·1 answer
  • Write the name of the tab, the command group, and the icon that you need to use to justify text
    9·1 answer
  • What specific type of DNS query instructs a DNS server to process the query until the server replies with an address that satisf
    5·1 answer
  • You don't have policies that force settings for the look of users' computer desktops. Each user's chosen desktop settings are ap
    15·2 answers
  • your computer running Windows 10 is doing some very strange things with operating system you are fairly certain it is not a hard
    13·2 answers
  • Name at least 3 different portable computer devices that can be purchased
    15·2 answers
  • NFPA 780, Standard for the Installation of Lightning Protection Systems provides information on the installation of _____ for li
    6·1 answer
  • Which of the following is an example of effective nonverbal communication?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!