Question

write a code in c++ using a conditional operater to determine if someone gets a speeding...

write a code in c++ using a conditional operater to determine if someone gets a speeding ticket based on how fast they were going

Homework Answers

Answer #1

Below is your code:

#include <iostream>
using namespace std;
int main() {
  //get speed from user
  int speed;
  cout<<"Enter your speed in kmph: ";
  cin>>speed;
  //conditional operator to check if speeding ticket is there or not
  bool speedingTiket = speed > 90? true: false;
  //printing the result
  if(speedingTiket) {
    cout<<"You got a speeding ticket. Please drive slow next time."<<endl;
  } else {
    cout<<"No Speeding ticket for you."<<endl;
  }
}

Output

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Code using C# Write a program that outputs “Welcome” five times
Code using C# Write a program that outputs “Welcome” five times
Can someone please write out the code in Mips assembly for calculating the nth root of...
Can someone please write out the code in Mips assembly for calculating the nth root of any number? I have been given the formula from someone here, which I am so grateful for, but I still need to see it in code. I'm new at this and practicing and need this code to work before I can move onto my real assignment and I can't figure out how to do it. Thank You!
Write a C# source code. Write a function called CircArea() that finds the area of a...
Write a C# source code. Write a function called CircArea() that finds the area of a circle. It should take an argument of type double and return an argument of the same type. Write a Main() method that gets a radius value from the user, calls CircArea(), and displays the result.
Write a C++ code snippet. To collect a number from the user and determine if the...
Write a C++ code snippet. To collect a number from the user and determine if the number is a positive , negative number or zero. (Hint: Look at the number's position relative to 0)
Write a C program that creates a security access code from a social security number entered...
Write a C program that creates a security access code from a social security number entered by a user as follows: Using a recursive function it adds all of the digits of the social security number and then using a regular function gets the square number of the sum and displays it. The access code displayed should be initialized as an integer number but using type casting is displayed as a floating number.
This is for programming using visual basic on visual studio. Write code to: a) Place the...
This is for programming using visual basic on visual studio. Write code to: a) Place the contents of txtQuantity into intQuantity. You should be able to determine what types of objects they are based upon their names. b) Using the objects, what value would be placed into intQuantity if the value of txtQuantity is 3.5?
Write an algorithm, without using compound conditional expressions, that takes in three integers and determines if...
Write an algorithm, without using compound conditional expressions, that takes in three integers and determines if they are all distinct. On average, how many comparisons does your algorithm do? Remember to examine all input classes.
C++ code: How to add a file to read/write to a code that prompt user to...
C++ code: How to add a file to read/write to a code that prompt user to add (write) infos and read infos from the file?
Using C++ code, write a program named q5.cpp to solve the equation 2n = 14.27 for...
Using C++ code, write a program named q5.cpp to solve the equation 2n = 14.27 for n.
Please write code in c++ using iostream library. Write a function that have to copy one...
Please write code in c++ using iostream library. Write a function that have to copy one char array to other avoiding any not-letter symbols, program have to use pointer. Input: First line contains sequence of chars (size is not more that 100). 1w[a3ter11 output: water
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT