Answer to Question #245407 in Java | JSP | JSF for ROY

Question #245407

v> Supposing you are operating a warehouse that receives and issues out items daily,

and at the end of each day, you take stock of the transactions. Answer the following

based on your knowledge in Java Programming.

a)

Provide a suitable name for your warehouse.

b)

Suggest the type of item you are dealing with and the cost of each item (e.g.

bags of cement at 50 cedis per bag).

c)

Write a Java programme named transactions.java that takes input from you in the

form of: positive integers representing the number of items brought in each time,

and negative integers representing the number of items issued out each time.

The programme will then calculate and print out the total number of items

received and issued out, as well as their corresponding total costs. Your

programme ends when the input is zero (0).




1
Expert's answer
2021-10-02T01:37:10-0400

1. Red oak

2. a) Bananas 1$ per kilo

b) Potatoes 1.5$ per kilo

c) Apples 1.2$ per kilo




import java.util.Scanner;

public class Transactions {
    public static void main(String[] args) {
        System.out.println("Red oak");
        Scanner in = new Scanner(System.in);
        int input;
        int totalIn = 0;
        int totalOut = 0;
        double cost = 1.5;
        while (true) {
            System.out.println("In:");
            input = in.nextInt();
            if (input == 0) {
                break;
            }
            totalIn += input;
            System.out.println("Out:");
            input = in.nextInt();
            if (input == 0) {
                break;
            }
            totalOut += input;
        }
        System.out.println("Total in: " + totalIn + ", total cost: " + totalIn * cost);
        System.out.println("Total out: " + totalOut + ", total cost: " + totalOut * cost);
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS