The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 3 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
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();
}