Answer:
- import java.util.Scanner;
-
- public class Main {
-
- static String invoiceNo;
-
- public static void main(String[] args) {
- shippingInvoice();
- System.out.printf("Invoice no: %s", invoiceNo);
- }
-
- public static void shippingInvoice(){
- Scanner input = new Scanner(System.in);
- System.out.print("Input invoice no: ");
- invoiceNo = input.nextLine();
- }
- }
Step-by-step explanation:
The solution is written in Java.
In the Java Main class, create a class variable, invoiceNo using keyword static (Line 5). The invoiceNo should be a string as it is supposedly composed of mixed numbers and letters.
Next, create the static method shippingInvoice (line 12 -16) that use Scanner object to get user input for the invoice number and assign it to the class variable invoiceNo.
In the main program, we call the shippingInvoice function and use printf method to print the invoice number (Line 8-9).