Jump to content


Photo

Car Cc - Need A List :s


  • Please log in to reply
26 replies to this topic

#16 jim4eva

jim4eva

    Mini Mad

  • Members
  • PipPipPipPip
  • 261 posts

Posted 02 June 2011 - 09:37 PM

In a cody format

if( cc < 900 ){
car = "under 1 litre"
}

if( cc > 900 AND cc < 1050){
car = "1 litre"
}

if( cc > 1050 AND cc < 1125){
car = "1.1 litre"
}

if( cc > 1125 AND cc < 1260){
car = "1.2 litre"
}


if( cc > 1260 AND cc < 1320){
car = "1.3 litre"
}


need that up to a 3litre really - but under the 2litre would be the most used i imagine

Something like that would work. It doesnt need to be accurate, just a best guess. As if the person enters 1275, it will be converted to 1.3 in the database. If someone entered say 1.25 like 998dave said, then it would be a 1.2 litre .... would this work?

Does that make sense? Apologies for sudocode it seemed easier


if it doesnt have to be accurate then how about this:

if( cc < 950 ){
car = "under 1 litre"
}

if( cc > 950 AND cc < 1049){
car = "1 litre"
}

if( cc > 1050 AND cc < 1149){
car = "1.1 litre"
}

if( cc > 1150 AND cc < 1249){
car = "1.2 litre"
}


if( cc > 1250 AND cc < 1349){
car = "1.3 litre"
}

if( cc > 1350 AND cc < 1449){
car = "1.4 litre"
}

if( cc > 1450 AND cc < 1549){
car = "1.5 litre"
}

if( cc > 1550 AND cc < 1649){
car = "1.6 litre"
}

and just keep going as high as you like.

I still dont understand why you would want to do this though?

GL1

I'm glad to see that we have a programming community among mini owners :D...
also I'm sure you know this but I thought I'd say it any way... and in programming can be symbolized with || ...
sorry if that's painfully obvious

#17 greenlaner1

greenlaner1

    Mini Mad

  • Members
  • PipPipPipPip
  • 285 posts

Posted 02 June 2011 - 09:45 PM

I'm glad to see that we have a programming community among mini owners :D...
also I'm sure you know this but I thought I'd say it any way... and in programming can be symbolized with || ...
sorry if that's painfully obvious


I work mainly with ladder logic so most of this stuff is foreign to me :o

is it just me or does this seem like something really very simple that has been made complicated?

GL1

#18 Dan

Dan

    On Sabbatical

  • TMF+ Member
  • PipPipPipPipPipPipPipPipPipPipPip
  • 21,354 posts

Posted 02 June 2011 - 10:03 PM

2 significant figures.... :D

GL1


Yes sorry, meant to say one significant figure after the decimal!

Actually I would say the 850 should be called a 0.9, it would be if it was launched today. Manufacturer's play all kinds of tricks with engine sizes. Fiat for example used to sell the exact same engine as two different sizes in two different countries to take advantage of engine displacement tax breaks from the two different governments. Other companies have done similar things and it's all just done by playing with the maths. They should really just all be rounded according to the accepted conventions of mathematics.

#19 jim4eva

jim4eva

    Mini Mad

  • Members
  • PipPipPipPip
  • 261 posts

Posted 02 June 2011 - 10:50 PM

I'm glad to see that we have a programming community among mini owners :D...
also I'm sure you know this but I thought I'd say it any way... and in programming can be symbolized with || ...
sorry if that's painfully obvious


I work mainly with ladder logic so most of this stuff is foreign to me :o

is it just me or does this seem like something really very simple that has been made complicated?

GL1


it is... you could use a switch statement which would make it much easier

#20 zelliott

zelliott

    Mini Mad

  • Members
  • PipPipPipPip
  • 159 posts

Posted 02 June 2011 - 11:19 PM

Well the smallest car Ive heard of in 50cc
And the biggest is 27 litres

and theres just anout everythign in between too (:

#21 chrisandsarah

chrisandsarah

    One Carb Or Two?

  • Members
  • PipPipPipPipPipPipPip
  • 746 posts

Posted 02 June 2011 - 11:48 PM

if it doesnt have to be accurate then how about this:

if( cc < 950 ){
car = "under 1 litre"
}

if( cc > 950 AND cc < 1049){
car = "1 litre"
}

if( cc > 1050 AND cc < 1149){
car = "1.1 litre"
}

if( cc > 1150 AND cc < 1249){
car = "1.2 litre"
}


if( cc > 1250 AND cc < 1349){
car = "1.3 litre"
}

if( cc > 1350 AND cc < 1449){
car = "1.4 litre"
}

if( cc > 1450 AND cc < 1549){
car = "1.5 litre"
}

if( cc > 1550 AND cc < 1649){
car = "1.6 litre"
}

and just keep going as high as you like.

I still dont understand why you would want to do this though?

GL1


Good idea - cheers! It is for a project - more because I want to allow people to have the choice of entering their cc aswell as say 1.2 because I dont want to have a dropdown with .9l 1l 1.1l etc

#22 chrisandsarah

chrisandsarah

    One Carb Or Two?

  • Members
  • PipPipPipPipPipPipPip
  • 746 posts

Posted 02 June 2011 - 11:51 PM

I'm glad to see that we have a programming community among mini owners :D...
also I'm sure you know this but I thought I'd say it any way... and in programming can be symbolized with || ...
sorry if that's painfully obvious


haha - yeah it was just sudo code for non programming people - thought it would be easier to understand than writing out a switch / case or full blown if statements.

it will all make sense when it is complete :o hopefully it is a project that everyone can make some use of :dontgetit:

#23 oli8925

oli8925

    Up Into Fourth

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,260 posts
  • Location: Kent

Posted 02 June 2011 - 11:58 PM

As Dan says, manufacturers fiddle it a lot anyway depending on the market criteria.

Also if you want to do the list properly, you should list the engine sizes in 'ci' too. Most of my workshop manuals for the Viva list the engine size in ci. The difference between tiny British engines and huge Amercan V8s seems even bigger in ci. Chevy big block - 427ci (up to 572 released in '03). My 1256 Viva - 76.6ci :D

998cc = 60.9ci
1275cc = 77.8ci

#24 chrisandsarah

chrisandsarah

    One Carb Or Two?

  • Members
  • PipPipPipPipPipPipPip
  • 746 posts

Posted 03 June 2011 - 12:00 AM

As Dan says, manufacturers fiddle it a lot anyway depending on the market criteria.

Also if you want to do the list properly, you should list the engine sizes in 'ci' too. Most of my workshop manuals for the Viva list the engine size in ci. The difference between tiny British engines and huge Amercan V8s seems even bigger in ci. Chevy big block - 427ci (up to 572 released in '03). My 1256 Viva - 76.6ci :D

998cc = 60.9ci
1275cc = 77.8ci


Hmm a little more in depth than I am wanting - but I didn't know that!!! cheers

#25 Deathrow

Deathrow

    Have you tried turning it off and on again?

  • TMF IT Specialist
  • PipPipPipPipPipPipPipPipPipPip
  • 5,734 posts
  • Name: Adam
  • Location: Manchester, UK

Posted 03 June 2011 - 01:40 AM

Do as Dan suggested. In Java:

double userIn = 1275;
		
System.out.println&#40;&#34;User entered &#34; + &#40;int&#41;userIn + &#34;cc&#39;s.&#34;&#41;;
		
//Share by 1000 and round.
DecimalFormat twoDForm = new DecimalFormat&#40;&#34;#.#&#34;&#41;;
double litres = Double.valueOf&#40;twoDForm.format&#40;userIn/1000&#41;&#41;;
		
System.out.println&#40;&#34;That&#39;s &#34; + litres + &#34;l.&#34;&#41;;
Output:

User entered 1275cc&#39;s.
That&#39;s 1.3l.
Note that the last character before the period is an l, not a 1.

Please lord don't use a massive switch statement, the cyclomatic complexity would be horrific.

#26 chrisandsarah

chrisandsarah

    One Carb Or Two?

  • Members
  • PipPipPipPipPipPipPip
  • 746 posts

Posted 03 June 2011 - 10:21 AM

......
Note that the last character before the period is an l, not a 1.

Please lord don't use a massive switch statement, the cyclomatic complexity would be horrific.


I am so thick! Did not think of doing it at way at all - you know when you puzzle over something silly for so long that you can no longer see a sensible answer, my Java days have long gone, but in PHP it would be...

$cc = &#34;1598&#34;;
$newCC = number_format&#40;&#40;$cc/1000&#41;, 1, &#39;.&#39;, &#39;&#39;&#41;;
echo &#34;The &#34;.$cc.&#34;cc engine is actually a &#34;.$newCC.&#34;<br />&#34;;

Edited by chrisandsarah, 03 June 2011 - 10:32 AM.


#27 Cerberus

Cerberus

    One Carb Or Two?

  • Members
  • PipPipPipPipPipPipPip
  • 989 posts
  • Location: near Leicester

Posted 04 June 2011 - 10:50 AM

In a cody format

if( cc < 900 ){
car = "under 1 litre"
}

if( cc > 900 AND cc < 1050){
car = "1 litre"
}

if( cc > 1050 AND cc < 1125){
car = "1.1 litre"
}

if( cc > 1125 AND cc < 1260){
car = "1.2 litre"
}


if( cc > 1260 AND cc < 1320){
car = "1.3 litre"
}


need that up to a 3litre really - but under the 2litre would be the most used i imagine

Something like that would work. It doesnt need to be accurate, just a best guess. As if the person enters 1275, it will be converted to 1.3 in the database. If someone entered say 1.25 like 998dave said, then it would be a 1.2 litre .... would this work?

Does that make sense? Apologies for sudocode it seemed easier


if it doesnt have to be accurate then how about this:

if( cc < 950 ){
car = "under 1 litre"
}

if( cc > 950 AND cc < 1049){
car = "1 litre"
}

if( cc > 1050 AND cc < 1149){
car = "1.1 litre"
}

if( cc > 1150 AND cc < 1249){
car = "1.2 litre"
}


if( cc > 1250 AND cc < 1349){
car = "1.3 litre"
}

if( cc > 1350 AND cc < 1449){
car = "1.4 litre"
}

if( cc > 1450 AND cc < 1549){
car = "1.5 litre"
}

if( cc > 1550 AND cc < 1649){
car = "1.6 litre"
}

and just keep going as high as you like.

I still dont understand why you would want to do this though?

GL1

I'm glad to see that we have a programming community among mini owners :)...
also I'm sure you know this but I thought I'd say it any way... and in programming can be symbolized with || ...
sorry if that's painfully obvious


|| = 'OR'
&& = 'AND'
! = NOT

so

if(cc > 1550 && cc < 1649)


if you used || (OR)

you'd end up with everything above 1550 and everything below 1649, so you'd have everything, so that wouldn't work.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users