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

68% Tue Feb 14 9 34 14 PM E Preview File Edit View Go Tools Window Help Introduc

ID: 3792605 • Letter: 6

Question

68% Tue Feb 14 9 34 14 PM E Preview File Edit View Go Tools Window Help Introduction to java programming by Y Daniel Liang 10th edition.pdf (page 133 of 1,345) a Search v Introduction to java.programmin... 3.7 Financial application: monetary units) Modify Listing 2.10, ComputeChange java, to display the nonzero denominations only, using singular words for single units such as dollar and 1 penny, and plural words for more than one unit such as 2 dollars and 3 pennies. 110 Chapter 3 Selections "3.8 (Sort three integers Write a program that prompts the user to enter three integers and display the integers in non-decreasing order. 10 3.9 (Business: check ISBN. 10 An ISBN-10 (International Standard Book Number Sort three integers consists of 10 digits: did2dadedsdedhdadkdio. The last digit, dho, is a checksum, which is calculated from the other nine digits using the following formula: If the checksum is 10, the last digit is denoted as X according to the ISBN-10 convention. Write a program that prompts the user to enter the first 9 digits and displays the 10-digit ISBN (including leading zeros). Your program should read the input as an integer. Here are sample runs: Enter the first 9 digits of an ISBN as integer: 013601267 The ISBN-10 number is 0136012671 Enter the first 9 digits of an ISBN as integer: 013031997 The ISBN-10 number is 013031997X 3.10 Game: addition quiz) Listing 3.3, SubtractionQuizjava, randomly generates a subtraction question. Revise the program to randomly generate an addition ques- tion with two integers less than 100 oaggarwa a students. Kennesaw.edu) session you at missio reason is considered late submission (see course syllabus Assignment Grading Policy)

Explanation / Answer

package chegg;

import java.util.Scanner;

public class CheckSum {
  
   //main method
   public static void main(String[] args) {
      
       Scanner sc=new Scanner(System.in);
       //Enter the first 9 Digits of an ISBN integer :
       System.out.println("Enter the first 9 Digits of an ISBN integer : ");
      
       String d1to9=sc.next();       
      
       int d10=0;
      
       System.out.println("Digit 1 to 9 is is:"+ d1to9);
      
       for(int i=0;i<d1to9.length();i++)
   {
   char c=d1to9.charAt(i);
   d10= d10 + (i+1)*Character.getNumericValue(c);   //013601267 013031997
   }
      
       d10=d10%11;
      
       if(d10==10)
       {
       System.out.println("Checksum is 10 so d10 is X");
       System.out.println("The ISBN 10 number is: "+d1to9+'X');
       }
       else{      
       System.out.println("d10 is is: "+d10);
       System.out.println("The ISBN 10 number is: "+d1to9+d10);
       }      
   }
}

-----------

output sample 1:-

Enter the first 9 Digits of an ISBN integer :
013601267
Digit 1 to 9 is is:013601267
d10 is is: 1
The ISBN 10 number is: 0136012671

------

output sample 2:-

Enter the first 9 Digits of an ISBN integer :
013031997
Digit 1 to 9 is is:013031997
Checksum is 10 so d10 is X
The ISBN 10 number is: 013031997X

---------------------------------------------------------------------------------------------

If you have any query, please feel free to ask.

Thanks a lot.