1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
vekshin1
4 years ago
14

Business: check ISBN-13) ISBN-13 is a new standard for identifying books. It uses 13 digits d1d2d3d4d5d6d7d8d9d10d11d12d13.

Computers and Technology
1 answer:
alexandr1967 [171]4 years ago
8 0

Answer:

Following are the code to this question:

#include <iostream>//defining header file

#include <string.h>//defining header file

using namespace std;//using package

char checksum(const char *x)//defining a method checksum  

{

int s=0,m,d;//defining integer variables

for (m= 1;*x;++x)//defining for loop for caLculate value

{

d=*x-'0';//use integer variable to remove last digit from input value  

s=s+m*d;//add value in s variable

m=4-m;//use m to remove 4 from m

}

return '0'+(1000-s)%10;//use return keyword to get value  

}

int main()//defining main method

{

char ISBNNum[14];// defining character array  

cout<<"Enter the first 12 digits of an ISBN-13 as a string:";//print message

cin>>ISBNNum;//input value from user end

if(strlen(ISBNNum)==12)//defining if block to check length

{

char a=checksum(ISBNNum);//defining char variable a to call method checksum

ISBNNum[12]=a;//use array to hold method value

ISBNNum[13]='\0';// use array to hold 13 character value

cout<<"The ISBN-13 number is "<<ISBNNum;//print number

}

else//defining else block

{

cout<<ISBNNum<<" is an invalid input"<<endl;//print message

}

return 0;

}

output:

please find the attachment.

Explanation:

In the given code a character method "checksum" is define that accepts a character as a parameter and inside the method, three integer variable "s,m, and d" is defined that uses the for loop to calculate the input value and use the return keyword for the return value.  Inside the main method, a char array "ISBNNum", is defined that input the value from the user-end and define the conditional statement.

  • In the if block, it uses "ISBNNum" char array that checks its length equal to 12, if this condition is true it defines char a to call the method and hold its value and use the array to sore value in a and its 13 lengths it stores "\0", and print its value.
  • If the condition is false, it will print input array value and print invalid input as a message.

You might be interested in
Please help me, i need help
Alchen [17]

Answer:

C or 5184000

Explanation:

i Have a MASSIVE brain

8 0
3 years ago
Read 2 more answers
Java
Triss [41]

The program illustrates the use of catching exceptions using try and catch.

  • Exceptions are simply errors that can crash a program
  • Try and catch are used to prevent errors from crashing a program

The required try and catch block is as follows:

<em>try { </em>

<em>        System.out.print(names[index]); </em>

<em>    } </em>

<em>    catch (ArrayIndexOutOfBoundsException e) { </em>

<em>   System.out.println(e.getMessage()); </em>

<em>}</em>

The flow of the above code segment is as follows:

First, we begin with the try block

<em>try {</em>

Then the program prints the element at the index

<em>        System.out.print(names[index]);     }</em>

If the index does not exist in the array (e.g. -1 or 11), then the catch block is executed

<em>    catch (ArrayIndexOutOfBoundsException e) {</em>

This prints the appropriate exception

<em>   System.out.println(e.getMessage()); }</em>

See attachment for sample run

Read more about similar programs at:

brainly.com/question/21330187

7 0
3 years ago
If a business owner wanted to create a banner ad for his business on his webpage, he could use Java programming to develop a (n)
hichkok12 [17]

The answer is applet

An applet is a fully functional Java application that is usually embedded within a HTML page and runs in a web browser. It has the entire Java API at its disposal and extends the java.applet.Applet class. Its class provides the standard interface between the applet itself and the environment of the browser.

8 0
4 years ago
Read 2 more answers
Does anyone know how to change there Name of the account that shows up? If you do please tell me in a comment and/or Answer.
Alona [7]

Answer:

change your email

Explanation:

award me brainliest

6 0
3 years ago
Read 2 more answers
Create a program that will play the “cows and bulls” game with the user. The game works like this: Randomly generate a 4-digit n
riadik2000 [5.3K]

Answer:

Welcome to the Cows and Bulls Game!

 Enter a number:

 >>> 1234

 2 cows, 0 bulls

 >>> 1256

 1 cow, 1 bull

 ...

"""

import random

def compare_numbers(number, user_guess):

   cowbull = [0,0] #cows, then bulls

   for i in range(len(number)):

       if number[i] == user_guess[i]:

           cowbull[1]+=1

       else:

           cowbull[0]+=1

   return cowbull

if __name__=="__main__":

   playing = True #gotta play the game

   number = str(random.randint(0,9999)) #random 4 digit number

   guesses = 0

   print("Let's play a game of Cowbull!") #explanation

   print("I will generate a number, and you have to guess the numbers one digit at a time.")

   print("For every number in the wrong place, you get a cow. For every one in the right place, you get a bull.")

   print("The game ends when you get 4 bulls!")

   print("Type exit at any prompt to exit.")

   while playing:

       user_guess = input("Give me your best guess!")

       if user_guess == "exit":

           break

       cowbullcount = compare_numbers(number,user_guess)

       guesses+=1

       print("You have "+ str(cowbullcount[0]) + " cows, and " + str(cowbullcount[1]) + " bulls.")

       if cowbullcount[1]==4:

           playing = False

           print("You win the game after " + str(guesses) + "! The number was "+str(number))

           break #redundant exit

       else:

           print("Your guess isn't quite right, try again.")

Explanation:

7 0
4 years ago
Other questions:
  • A video game character prefers to take enemies on from a distance. What skills might such a character have?
    11·2 answers
  • What is the problem we can't build shelter on mars ?
    6·1 answer
  • • Two advertisers A and B
    8·1 answer
  • Splunk uses ________ to categorize the type of data being indexed..
    11·2 answers
  • Hi need help on this <br> what is cyberspace
    14·1 answer
  • I need help. I wanna help a friend by giving him my powerpoint but I dont want him to steal my work. Is their anyway to restrict
    8·1 answer
  • What size segment will be allocated for a 39 KB request on a system using the Buddy system for kernel memory allocation?A) 42 KB
    11·1 answer
  • __ allow(s) users with mobility issues to control the computer with their voice.
    6·2 answers
  • Sarah is a detall-oriented programmer. While testing her program, what other skill would she have to apply in order to detect al
    9·1 answer
  • Drag the tiles to the correct boxes to complete the pairs.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!