Question: create a Word document that contains the pseudocode, flowchart, and test plan Project 6 import java.util.Scanner; public class Exercise 0 5 _ 4 7 {

create a Word document that contains the pseudocode, flowchart, and test plan
Project 6
import java.util.Scanner;
public class Exercise05_47{
public static void main(String[] args){
Scanner input = new Scanner(System.in);
System.out.print("Enter the first 12 digits of an ISBN-13 as a string: ");
String inputStr = input.nextLine();
if (inputStr.length()!=12||!inputStr.matches("[0-9]+")){
System.out.println(inputStr +" is an invalid input");
} else {
int sum =0;
for (int i =0; i < inputStr.length(); i++){
int digit = Character.getNumericValue(inputStr.charAt(i));
if (i %2==0){
sum += digit;
} else {
sum +=3* digit;
}
}
int checksum =10-(sum %10);
if (checksum ==10){
checksum =0;
}
System.out.println("The ISBN-13 number is "+ inputStr + checksum);
}
input.close();
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!