0

Hi im programming a program thats going to count how how many doussins,grosses and pieces. there are if you enter a number. (just so u know ive started programming 1 week ago and havent programed alot cause school started) ok heres my problem: when i enter 502 pieces it says it 3grosses 3doussins and 10 pieces it should be 3,5,10 so doussins is wrong, if u look where it says antdussin=totantstycken/144; so maybe this problem is cause im not so good with math but i think 1 gross is 144 pieces and a doussin is 12 pieaces right?

# include <iostream>
# include <iomanip>
using namespace std;
int main()
{
 int totantstycken, antgross, antdussin,antstycken;
 cout<<"Ange antal:";
 cin>>totantstycken;
 antgross=totantstycken/144;
 antdussin=totantstycken/144;
 antstycken=totantstycken%12;
 cout<<totantstycken<<" sekunder bestar av "<<endl;
 cout<<"Gross"<<setw(5)<<antgross<<endl;
 cout<<"Dussin"<<setw(4)<<antdussin<<endl;
 cout<<"Stycken"<<setw(3)<<antstycken<<endl;
}
3
Contributors
3
Replies
4
Views
12 Years
Discussion Span
Last Post by RobinA
0

then it must be your wrong statement of calculation which happened twice
antgross=totantstycken/144;
antdussin=totantstycken/144;

i think...

0

antgross=totantstycken/144;
antdussin=totantstycken/144;

u again divide the same value on the same divisor u must
replace the line :antdussin=totantstycken/144; with the following two lines :
totantstycken%=144; //get the nuber of non gross piesec
antdussin=totantstycken/12; //get the number of dussin

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.