Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C --- code Everything on C code import java.util.Scanner; class checksum{ public static void main(String args[]){ final int max_int = 255; // the maxium size

C --- code

Everything on C code

import java.util.Scanner; class checksum{ public static void main(String args[]){ final int max_int = 255; // the maxium size for the input int count = 10; // the number of integers to read from stdin int sum = 0; // Note that the "sum" might exceed max_int int checksum = 0; // The value of the 6th input integer int quotient; // The result of evaluating the assignment: quotient = sum / (max_int + 1); int remainder; // The result og evaluating the assignment: remainder = sum % (max_int + 1); int complement; // The result of evaluating the assignment: complement = max_int - sum; System.out.println("Enter 10 numbers from 0-255"); Scanner stdin = new Scanner(System.in);

for(int i =0; i < count; i++){ int value = stdin.nextInt(); if(value >= 0 && value <= max_int){ if(i == 5){ checksum = value; value = 0; } sum += value;

} } quotient = sum / (max_int + 1); remainder = sum % (max_int + 1); sum = quotient + remainder; complement = max_int - sum; System.out.printf("Stored Checksum: %d, Computed Checksum: %d ", checksum, complement); if (checksum != complement){ System.err.printf("Error Detected! "); } } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional SQL Server 2012 Internals And Troubleshooting

Authors: Christian Bolton, Justin Langford

1st Edition

1118177657, 9781118177655

More Books

Students also viewed these Databases questions

Question

Ty e2y Evaluate the integral dy

Answered: 1 week ago