Question

Write a small program using C++, that does the following using the Conditional Operator only. Prompts...

Write a small program using C++, that does the following using the Conditional Operator only.

  • Prompts user to input a score between 1-6 (assume the user will honor the request)
  • Stores the user input in an appropriate variable (appropriate in type and name)
  • Checks if the score is a passing grade. Assume 70% or more is needed
  • Displays a message if the score is passing or if the score is not a passing score

Include a test table in the comments below main

Include a test table in the comments below main

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code:

#include<iostream>
using namespace std;
int main(){
   float a,b;
   cout<<"enter your score between 1-6:";      //reading input from user.
   cin>>a;
   b=(70/100)*6;              //calculating 70%
   (a>=b)?cout<<"your score is passing":cout<<"your score is not passing"; //conditional operator used.
  
}

Test table:

INPUT EXPECTED OUTPUT ACTUAL OUTPUT
1 your score is not passing your score is not passing
4.2 your score is passing your score is passing
Add a comment
Know the answer?
Add Answer to:
Write a small program using C++, that does the following using the Conditional Operator only. Prompts...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a C++ Program Write a program that prompts the user to input a number. The...

    Write a C++ Program Write a program that prompts the user to input a number. The program should then output the number and a message saying whether the number is positive, negative, or zero. You must insert the following comments at the beginning of your program and write our commands in the middle: Write a C++ Program: 1 Name: Your Name ID: Your ID #include <iostream> using namespace std; din main YOUR CODE HERE

  • Using C++ language P2-4 Write a program that randomly generates an integer and then prompts the...

    Using C++ language P2-4 Write a program that randomly generates an integer and then prompts the user to guess the number. If the user guesses the number correctly, the program outputs an appropriate message such as "You win!" and terminates. Otherwise, the program checks and tell the user whether the guessed number is less or greater than the target number and then prompts him for another try. However, the program gives the user five tries only to guess the correct...

  • 1. Palindrome Write a program that prompts the user for a positive integer number and output whet...

    Language is C 1. Palindrome Write a program that prompts the user for a positive integer number and output whether the number is a palindrome or not. A palindrome number is a number that is the same when reversed. For example, 12321 is a palindrome; 1234 is not a palindromoe. You will write a function named as palindrome. The function will have two arguments, number and isPalindrome. Both arguments are pass-by-reference. The argument number is a pointer to a variable...

  • Program must be in Python 3. Write a program that prompts the user to enter two...

    Program must be in Python 3. Write a program that prompts the user to enter two strings and then displays a message indicating whether or not the first string starts with the second string. Your program must satisfy the following requirements. 1. Your program must include a function called myStartsWith that takes two string parameters. This function returns True if the rst string starts with the second string and returns False otherwise. 2. Your program must include a main function...

  • In C++, Write a program that it prompts to user for two integers, computes the quotient...

    In C++, Write a program that it prompts to user for two integers, computes the quotient of two integers, and then displays the result. You need to do the following things in this assignment: + The main function prompts for user input and reads the two integers that the user entered. + Write a quotient function that computes the quotient of two integers and return the results. (hint: avoid integer division and divide by zero)

  • Python 3 **11.40 (Guess the capitals) Write a program that repeatedly prompts the user to enter...

    Python 3 **11.40 (Guess the capitals) Write a program that repeatedly prompts the user to enter a capital for a state. Upon receiving the user input, the program reports whether the answer is correct. Assume that 50 states and their capitals are stored in a two- dimensional list, as shown in Figure 11.13. The program prompts the user to answer all the states’ capitals and displays the total correct count. The user’s answer is not case sensitive. Implement the program...

  • Write a c++ program that does the following: in main() 1. prompts for a student's name...

    Write a c++ program that does the following: in main() 1. prompts for a student's name (with spaces_ 2. prompts for 3 grades 3. Calls a function to calculate the average of the 3 grades - arguments must be passed by value 3. displays the student's name and average grade - example: Fred Smith : 85.5 - the average should be a float displaying 1 digit of precision

  • PLEASE INCLUDE COMMENTS In java Create a Java Program Add the following comments at the beginning...

    PLEASE INCLUDE COMMENTS In java Create a Java Program Add the following comments at the beginning of the file: Your name. The name of the class(es) used in the program. The core concept (found below) for this lesson. The date the program was written. Include a recursive method separate from the main method that will add together all of the even numbers between and including 1 and the value the user supplies. For instance, if the user enters 10 then...

  • Write a JAVA program that prompts the user for student grades and displays the highest and...

    Write a JAVA program that prompts the user for student grades and displays the highest and lowest grades in the class. The user should enter a character to stop providing values. Starter code: import java.util.Scanner; public class MaxMinGrades{   public static void main(String[] args){     Scanner input = new Scanner(System.in);     System.out.println("Enter as many student grades as you like. Enter a character to stop.");     double grade = input.nextDouble();     double minGrade = Double.MAX_VALUE;     double maxGrade = Double.MIN_VALUE;     while (Character.isDigit(grade)) {       if (grade == 0)...

  • Design a modular program using pseudo-code which prompts a user for their first name, followed by...

    Design a modular program using pseudo-code which prompts a user for their first name, followed by their last name; then displays a "Hello" salutation which concatenates their first name with their last name. Sample output (user input shown in red): Please enter your first name: John Please enter your last name: Smith Hello, John Smith! Your program must include a main module and one function; this function prompts the user for either their first name or last name, using a...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT