Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Psuedocode and JAVA code not using if or else statements. Imagine that you are a

ID: 3877724 • Letter: P

Question

Psuedocode and JAVA code not using if or else statements.

Imagine that you are a merchant and need to keep better tabs on your merchandise to know when to reorder supplies.
First, write out pseudocode, and then create a program to help you by accomplishing the following tasks:
Ask the user to input the following. (You will need to convert this from a string to an integer.)
   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 a dialog box 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.

Ensure your program performs its intended function.

Explanation / Answer

Here you goo...

Psuedocode:

begin

aoh = apples on hand

ans = apples need to stock

ooh = oranges on hand

ons = oranges need to stock

take input from user;

checking for apples

if (ans>aoh)

{

reorder(ans-aoh amount of applse);

}

else if(ans<aoh)

{

you have enough applse;

}

else if (ans==aoh)

{

you have exact amount of applse

your wish to reorder

}

checking for oranges

if (ons>ooh)

{

reorder(ans-aoh amount of oranges);

}

else if(ons<ooh)

{

you have enough oranges;

}

else if (ons==ooh)

{

you have exact amount of oranges

your wish to reorder

}

finish.

Java Code is Here :

import java.util.*;

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

public class Da extends JFrame

{

public static void main(String []args)

{

int apples_on_hand,apples_need_stock;

int oranges_on_hand,oranges_need_stock;

Scanner input = new Scanner(System.in);// to take the input from the user keyboard you need this obj.

System.out.print("How many apples are on hand : ");

String ah = input.next();// to store apples on the hand

System.out.print("How many apples should be in stock : ");

String an = input.next();// to store apples need to be stored

System.out.print("How many Oranges are on hand : ");

String oh = input.next();// to store oranges on the hand

System.out.print("How many Oranges should be in stock : ");

String on = input.next();// to store oranges need to be stored

try

{

apples_on_hand = Integer.parseInt(ah);// converting string into int

apples_need_stock = Integer.parseInt(an);// converting string into int

oranges_on_hand = Integer.parseInt(oh);// converting string into int

oranges_need_stock =Integer.parseInt(on);// converting string into int

if (apples_need_stock>apples_on_hand)// checking if need > on hand

{

//then you need to reorder more

//System.out.println("You need to reorder "+(apples_need_stock - apples_on_hand)+" more apples!");

JOptionPane.showMessageDialog(null,"You need to reorder "+(apples_need_stock - apples_on_hand)+" more apples!");

}

else if (apples_need_stock<apples_on_hand)

{

// need < on hand then no need to order

//System.out.println("You have enough apples!");

JOptionPane.showMessageDialog(null,"You have enough apples!");

}

else if (apples_need_stock==apples_on_hand)

{

// if need==onhand then

// System.out.println("You have exact amout of apples!");

// System.out.println("Your Wish to order more!");

JOptionPane.showMessageDialog(null,"You have exact amout of apples! Your Wish to order more!");

}

if (oranges_need_stock>oranges_on_hand)

{

JOptionPane.showMessageDialog(null,"You need to reorder "+(oranges_need_stock - oranges_on_hand)+" more Oranges!");

// System.out.println("You need to reorder "+(oranges_need_stock - oranges_on_hand)+" more Oranges!");

}

else if (oranges_need_stock<oranges_on_hand)

{

// System.out.println("You have enough Oranges!");

JOptionPane.showMessageDialog(null,"You have enough Oranges!");

}

else if (oranges_need_stock==oranges_on_hand)

{

// System.out.println("You have exact amout of Oranges!");

// System.out.println("Your Wish to order more!");

JOptionPane.showMessageDialog(null,"You have exact amout of Oranges! Your Wish to order more!");

}

}catch(Exception e)

{

System.out.println("Invalid Inputs!");

System.out.println("Please Enter Integers only!");

}

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote