- #include<conio.h>
-
#include<iostream>
-
-
using namespace std;
-
int main()
-
{
-
double ManfCode,ProdCode;
-
int Checkdigit, SecondManf, FourthManf;
-
int FirstProd,ThirdProd,FifthProd;
-
int SecondProd,ForthProd;
-
int FirstManf,ThirdManf,FifthManf;
-
int endA, endB, endC, endD, endE, endF, endG;
-
int assist1=0,assist2=0,assist3=0;
-
-
cout<<"Please enter the Manufacturer Code below"<<endl;
-
cin>>ManfCode;
-
if((ManfCode > 99999)||(ManfCode<10000)) {cout<<"Error, Re-Enter the Manufacturer Code"<<endl;
-
cin>>ManfCode;}
-
cout<<"Please enter the Product Code below"<<endl;
-
cin>>ProdCode;
-
if((ProdCode > 99999)||(ProdCode<10000)) {cout<<"Error, Re-enter the Product Code"<<endl;
-
cin>>ProdCode;}
-
cout<<"Please enter the Check Digit below"<<endl;
-
cin>>Checkdigit;
-
if((Checkdigit > 9)||(Checkdigit<0)) {cout<<"Error, Re-enter the Check Digit"<<endl;
-
cin>>Checkdigit;}
-
cout <<"The UPC code you entered is \n"<< "0 "<<ManfCode<<" "<<ProdCode<<" "<<Checkdigit<<endl;
-
assist1= 10000% ManfCode;
-
SecondManf= static_cast<int>(assist1/1000);
-
cout <<"The second number for the manufacturer is " <<SecondManf<<endl;
-
assist2= (int)ManfCode % 100;
-
FourthManf= static_cast<int>(assist2/10);
-
cout <<"The fourth number for the manufacturer is " <<FourthManf<<endl;
-
-
endA= SecondManf+FourthManf;
-
cout <<"The end result for the second and the fourth manufacturer is " <<endA <<endl;
-
-
-
-
-
getch();
-
-
return 0;
-
}
Its just the beginning
Thats my code for Validating A UPC Code
How do i eliminate the error?
I got this error: error C2297: '%' : illegal, right operand has type 'double'
2 7150 Banfa 9,065
Recognized Expert Moderator Expert
Don't use % on variables on type double, it only works on the integer types (char, short, int, long, long long).
Does the manufactures code really have to have type double? Normally codes like that are integers, or rather a string of digits representable as an integer.
Oralloy 988
Recognized Expert Contributor
Since you don't tell us which line your problme occurred on, I'll assume its line 28, where you take 10,000 modulo ManfCode.
I'd ask why lines 28 and 31 read differently. I infer that you're pulling a particular digit out of the code, or is there some other magic going on? If not, I think line 28 should be updated to read - assist1= (long)ManfCode % 10000;
Please, next time you post remember to use code tags and note the exact line where the error occurred. We're not mind readers.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Martin Koekenberg |
last post by:
Hello,
Ik get the following error when I install a new Python software
package such as Zope or PIL.
This is what I get whem I 'make' Zope :
running build_ext
Traceback (most recent call last):
File "/usr/local/zope/Zope-2.7.2-0/setup.py", line 1091, in ?
|
by: Rakesh |
last post by:
In my Python code fragment, I want to write a code fragment such that
the minimum element of a tuple is subtracted from all the elements of a
given
tuple.
When I execute the following python script I get the following
interpreter
error.
|
by: Tim Mierzejewski |
last post by:
You guys were so great with answering my first question that I've decided to
ask you yet again! Again, only the relevant code is included.
typedef unsigned int unint;
#include <iostream>
class Creature
{
public:
unint ReturnSpellPoints() {return crSpellPoints;}
|
by: Ondrej Spanel |
last post by:
The code below does not compile with .NET 2003, I get folowing error:
w:\c\Pokusy\delegTemplArg\delegTemplArg.cpp(11) : error C2993: 'float' :
illegal type for non-type template parameter 'x'
The error shows compiler is quite confused - x is not a template parameter
at all.
I have found two workarounds, but still I think the code should compile.
|
by: BlueTrin |
last post by:
Hello I was adapting a C version of SolvOpt in C++ to use it within a
virtual class.
However I am stuck with the overriding of evaluation and gradiant
functions.
cStepCurveEvaluator.cpp
cStepCurveEvaluator.cpp(14) : error C2296: '.*' : illegal, left operand
| |
by: duraisridhar |
last post by:
Hi all,
While I try to find the modulus on double data , Compiler throws
following error
"Test.cpp(180): error C2296: '%' : illegal, left operand has type
'double' "
Any work around to over come this compiler error .
|
by: dobbouk |
last post by:
I'm getting these 2 errors and haven't got a clue whats causing them please
java 43: illegal start of type
for (i=0;i< Number_of_squares; i++)
java 215 identifier expected
}
heres the whole code
|
by: su817200 |
last post by:
Dear Friend,
I got the following build error
error C2297: '*' : illegal, right operand has type 'unsigned long *'
register unsigned char *outof;
register unsigned long *into;
*into |= (*outof++ & 0xffL) << 16;
|
by: Terry Archer |
last post by:
error C2296: '%' : illegal,left operand has type 'double'
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
const int OUNCES_PER_POUND = 16;
const double POUNDS_PER_KILOGRAM = 2.2;
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| | |