Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Program for car crash  RSS feed

 
Jesse Kaiser
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I have never done programming in my life before I started taking a class this semester. This weeks program assignment is to get a program to print out if you got in a wreck or if you didnt. So far I have this as my program, but when I go to compile it, after entering the speed and the distance they all print out at the same time. How do I get it to just print out one at a time depending on the distance and speed?


 
Phil English
Ranch Hand
Posts: 62
MySQL Database Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The semi-colons after your if statements terminate the clause early.

This code:

Says: check if condition is true then do nothing about it. Then, completely separately, dothis.

What you want is:



Which says: if condition is true then dothis.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!