How do i write the pseudocode for this java code? First, write out pseudocode, and then create a program to help you by accomplishing the following tasks:
: Use command line interface to ask the user to input the following.
○ How many apples are on hand ○ How many apples should be in stock ○ How many oranges are on hand ○ How many oranges should be in stock
Perform an operation to determine how many of each item should be ordered to maintain the stock.
Use command line interface to output the number of apples and oranges that need to be ordered. Once you have the program laid out, build it by creating a functional program. Use your pseudocode as a guide. Be sure to remember the following important items:
Follow the style guidelines found in ZyBooks as you develop.
Use commenting to describe the code.
Practice debugging if you encounter errors.
Ensure your program performs its intended function. Specifically, the following critical elements must be addressed:
I. Documentation: Pseudocode: Break down the problem statement into programming terms through creation of pseudocode following the guidelines provided in the course.
II. Functioning Code: Produce fully functioning code (a code that produces no errors) that aligns with the accompanying annotations.
III. Code Results: Results are properly generated. A. Code results generate accurate output. B. Code results produce results that are streamlined, efficient, and error free.
IV. Comments: All code should be well-commented. This is a practiced art that requires striking a balance between commenting everything, which adds a great deal of unneeded noise to the code, and commenting nothing. A. Explain the purpose of lines or sections of your code, detailing the approach and method the programmer took to achieve a specific task in the code.
V. Style and Structure: Part of the lesson to be learned in this course is how to write code that is clearly readable and formatted in an organized manner. A. Develop logically organized code that can be modified and maintained. B. Utilize proper syntax, style, and language conventions and best practices.
Part I - Psedocode
Pseudocode
Function stockinfo
1. declare the necessary variables, on our case
applesOnHand,applesInStock, orangesOnHand, orangesInStock
2. Create a scanner to read the user input from
command line. This is included in the java.util.Scanner package.
hence we have to import this to our program
3. Ask the required questions and assign the values,
which the user enter to the corresponding variables already
created.
1. Get the number of apples on
Hand.
2. Get the number of Apples that
should be in stock
3. Get the number of Oranges on
Hand.
4. Get the number of Oranges that
should be in stock
4. Do the logical calculation.
1. If Apples in hand is less than
the number of apples that are supposed to be in stock we should re
order apples
2. Else display Sufficient Apples
are available
3. If Oranges in hand is less than
the number of Oranges that are supposed to be in stock we should re
order Oranges
4. Else display Sufficient Oranges
are available
Part II - Functional code
import java.util.Scanner;
public class stockinfo {
public static void main(String[] args) {
// Declare the necessary
variables
int applesOnHand,applesInStock,
orangesOnHand, orangesInStock;
//Create a scanner to read the user
input from command line. This is included in the java.util.Scanner
package. hence we have to import this to our program
Scanner scnr = new
Scanner(System.in);
//Ask the required questions and
assign the values, which the user enter to the corresponding
variables already created.
//Get the number of apples on
Hand.
System.out.println("Enter How many
apples are there on Hand :");
applesOnHand =
scnr.nextInt();
//Get the number of Apples that
should be in stock
System.out.println("Enter How many
apples should be in Stock :");
applesInStock=
scnr.nextInt();
//Get the number of Oranges on
Hand.
System.out.println("Enter How many
Oranges are there on Hand :");
orangesOnHand=
scnr.nextInt();
//Get the number of Oranges that
should be in stock
System.out.println("Enter How many
Oranges should be in Stock :");
orangesInStock=
scnr.nextInt();
// Do the logical calculation and
print the desired output
if(applesOnHand<applesInStock)
System.out.println("Reorder "+(applesInStock-applesOnHand)+"
Apples. ");
else
System.out.println("Sufficient Apples in Stock ");
if(orangesOnHand<orangesInStock)
System.out.println("Reorder "+(orangesInStock-orangesOnHand)+"
Oranges. ");
else
System.out.println("Sufficient Oranges in Stock ");
return;
}
}
Part III - Output
Enter How many apples are there on Hand :
20
Enter How many apples should be in Stock :
15
Enter How many Oranges are there on Hand :
15
Enter How many Oranges should be in Stock :
20
Sufficient Apples in Stock :
Reorder 5 Oranges !!!
Part IV and V are inline and taken care of.
Thanks,
How do i write the pseudocode for this java code? First, write out pseudocode, and then create a program to help you by accomplishing the following tasks: : Use command line interface to ask the use...
this assingent is to pseudocode, i have instructions
and the example my teacher had given me for this, could i have some
assistance, i need to do this in netbeans IDE and i need to use the
scanner method as well and i need to pass both.
Overview: This assignment will allow you to use pseudocode to implement the program to see the value in planning first, coding later. While coding is the glamorous part of the job, software development is...
Java Branches code not working please HELP!! I am trying to build this class that will ask for an ingredient, and the number of cups of the ingredient. It should then branch into an if/else branch off to verify that the number entered is valid and that it is within range. Once that branch completes it should then continue on to ask for the calories per cup, and then calculate total calories. Once I get it to enter the branch...
How do I add the space that this Zybooks
code keeps asking me to add?
5.13 LAB: Output numbers in reverse Write a program that reads a list of integers, and outputs those integers in reverse. The input begins with an integer indicating the number of integers that follow. For coding simplicity, follow each output integer by a space, including the last one. Assume that the list will always contain fewer than 20 integers. Ex: If the input is: 5...
need help editing or rewriting java code, I have this program
running that creates random numbers and finds min, max, median ect.
from a group of numbers,array. I need to use a data class and a
constructor to run the code instead of how I have it written right
now. this is an example of what i'm being asked
for.
This is my code:
import java.util.Random;
import java.util.Scanner;
public class RandomArray {
// method to find the minimum number in...
How to build Java test class? I am supposed to create both a recipe class, and then a class tester to test the recipe class. Below is what I have for the recipe class, but I have no idea what/or how I am supposed to go about creating the test class. Am I supposed to somehow call the recipe class within the test class? if so, how? Thanks in advance! This is my recipe class: package steppingstone5_recipe; /** * *...
I need help with my Java code. A user enters a sentence and the program will tell you what words were duplicated and how many times. If the same word is in the sentence twice, but one is capitalized, it will not count it as a duplicate. How can I make the program read the same word as the same word, even if one is capitalized and the other is not? For example, "the" and "The" should be counted as...
How would you write the following program using switch statements instead of if-else statements (in java) import java.util.*; public class ATM { public static void main(String[] args) { Scanner input = new Scanner (System.in); double deposit, withdrawal; double balance = 6985.00; //The initial balance int transaction; System.out.println ("Welcome! Enter the number of your transaction."); System.out.println ("Withdraw cash: 1"); System.out.println ("Make a Deposit: 2"); System.out.println ("Check your balance: 3"); System.out.println ("Exit: 4"); System.out.println ("***************"); System.out.print ("Enter Your Transaction Number "); transaction...
Hello! I have a Java homework question that I could really use some help with. I keep getting an error, but I don't know what is wrong with my code. Thanks so much in advance! The problem is: 6.9: VowelAnalyst Design and implement an application that reads a string from the user, then determines and prints how many of each lowercase vowel (a, e, i, o, and u) appear in the entire string. Have a separate counter for each vowel....
I need to create a code for this prompt: In this project we will build a generic UserInput class for getting keyboard input from the user. Implementation: The class UserInput is a 'Methods only' class, and all the methods should be declared static. Look at the TestScanner.java program at the bottom of this page that inputs a string, int and double. It shows you how to use Scanner class to get input from the keyboard. Write FOUR simple methods, one...
Help pls! and kindly explain how you do this as well. Thaank you Write a program to test whether a square is a 3x3 magic square. A magic square is a grid with 3 rows and 3 columns, like the figure below. A magic square has the following properties: the grid contains only the numbers 1 through 9 the sum of each row, each column, and each diagonal all add up to the same number Notes: I have provided the...