ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 103 Weeks Ago, 3 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 02 May 2017 My Price 8.00

public class ValidationUPC

Could you please help me with this project in the following link: 

http://web.cse.ohio-state.edu/cse1223/currentsem/projects/CSE1223Project06.html

This is what I have so far:

import java.util.Scanner;

public class ValidationUPC {

final long L = 999999999999L;

Scanner inputUPC = new Scanner(System.in);

System.out.print("Enter a 12-digit UPC : ");

long inputUPCC = inputUPC.nextLong();

long CV = inputUPCC;

if ((CV>= 0) && (CV < L)) {

int n12 = (int) (CV % 10);

CV /= 10;

int n11 = (int) (CV % 10);

CV /= 10;

int n10 = (int) (CV % 10);

CV /= 10;

int n9 = (int) (CV % 10);

CV /= 10;

int n8 = (int) (CV % 10);

CV /= 10;

int n7 = (int) (CV % 10);

CV /= 10;

int n6 = (int) (CV % 10);

CV /= 10;

int n5 = (int) (CV % 10);

CV /= 10;

int n4 = (int) (CV % 10);

CV /= 10;

int n3 = (int) (CV % 10);

CV /= 10;

int n2 = (int) (CV % 10);

CV /= 10;

int n1 = (int) (CV % 10);

CV /= 10;

int oddSum = n1 + n3 + n5 + n7 + n9 + n11;

int evenSum = n2 + n4 + n6 + n8 + n10;

int ccheck = 10 - ((evenSum + 3 * oddSum) % 10);

if (ccheck == n12) {

System.out.println(inputUPCC + " is a valid UPC code");

}

else {

System.out.println(inputUPCC + " is not a valid UPC code");

}

}

public static void main(Strings args[])

{

class ValidationUPC=new ValidationUPC();

}

Answers

(11)
Status NEW Posted 02 May 2017 03:05 AM My Price 8.00

-----------

Not Rated(0)