Answer:
- #include <iostream>
- using namespace std;
- int main() {
- int number =5;
- if (number>=0&& number <=100){
- cout<<"passed.\n";
- }
- else{
- cout<<"failed.\n";
- }
- return 0;
- }
Explanation:
There where multiple errors in the code given in the questions
Line 1: Missing <iostream>
Line 5: The comparison operator was wrong correction is highlighted
Line 12 Missing closing brace for the main function
All the errors have been fixed and the code above compiles
Answer:
hope this helps if not srry
Answer:
In Java:
import java.util.*;
public class Main{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String isbn;
System.out.print("First 1:2 digits: ");
isbn = input.nextLine();
if(isbn.length()==12){
int chksum = 0;
for(int i = 0; i<12;i++){
if((i+1)%2==0){ chksum+= 3 * Character.getNumericValue(isbn.charAt(i)); }
else{ chksum+=Character.getNumericValue(isbn.charAt(i)); } }
chksum%=10;
chksum=10-chksum;
if(chksum==10){
System.out.print("The ISBN-13 number is "+isbn+"0");}
else{
System.out.print("The ISBN-13 number is "+isbn+""+chksum); } }
else{
System.out.print("Invalid Input");
} }}
Explanation:
See attachment for explanation where comments are used to explain each line
The expression NOT (3+2=7) evaluates as TRUE because is is NOT the case that 3+2=7.
Let me know if you have any questions.
Was this a question on an assignment or are you in an asylum right now