Question

This question is for a C++ course. This is all the information given. Please help answering...

This question is for a C++ course. This is all the information given. Please help answering this question.

"The < and == operators for the class Record have already been implemented for you. Write the code necessary to complete the >, <=, >= and != operators. (hint: you do not need to know anything about the Record class to complete)"

In Java, for the same question, the solution is below. However, I need help for C++ similar to what is below...

public class Record {

   public static void main(String[] args) {
       int a = 5, b = 4;
       // for > operator true or false
      
       System.out.println((a > b)); // returns true
       a = 4;
       b = 5;
       System.out.println((a > b)); // returns false

       // for <= true or false
       a = 5;
       b = 4;
       System.out.println((a <= b)); // returns false
       a = 4;
       b = 5;
       System.out.println((a <= b)); // returns true

       // for >= true or false
       a = 5;
       b = 4;
       System.out.println((a >= b)); // returns true
       a = 4;
       b = 5;
       System.out.println((a >= b)); // returns false

       // for != true or false
       a = 5;
       b = 4;
       System.out.println((a != b)); // returns true
       a = 5;
       b = 5;
       System.out.println((a != b)); // returns false
   }
}

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

#include <iostream>

using namespace std;

int main() {

//in c++, false is considered as 0 and

//true is as 1.

int a = 5, b = 4;

cout << (a > b) << endl;

a = 4;

b = 5;

cout << (a > b) << endl; // returns 0

// for <= true or false

a = 5;

b = 4;

cout << (a <= b) << endl; // returns 0

a = 4;

b = 5;

cout << (a <= b) << endl; // returns true

// for >= true or false

a = 5;

b = 4;

cout << (a >= b) << endl; // returns 1

a = 4;

b = 5;

cout << (a >= b) << endl; // returns 0

// for != true or false

a = 5;

b = 4;

cout << (a != b) << endl; // returns 1

a = 5;

b = 5;

cout << (a != b) << endl; // returns 0

}

IF THERE IS ANYTHING THAT YOU DO NOT UNDERSTAND, OR NEED MORE HLP THEN PLEASE MENTION IT IN THE COMMENTS SECTIN.

Add a comment
Know the answer?
Add Answer to:
This question is for a C++ course. This is all the information given. Please help answering...
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
  • easy question but i am confused. someone help Consider the following Java classes: class OuterClass {...

    easy question but i am confused. someone help Consider the following Java classes: class OuterClass { static class InnerClass { public void inner Method({ System.out.println("This is my inner class"); public static void outer Method{ System.out.println("This is my outer class"); public class OuterClass Test{ public static void main(String args[]) { Complete the class OuterClass Test to produce as output the two strings in class OuterClass. What are the outputs of your test class?

  • I need help answering a question in JAVA. Also could you explain exactly what is be...

    I need help answering a question in JAVA. Also could you explain exactly what is be asked from this question. I will be including the driver class and one function that needs to be answered. import java.util.Arrays; public class A2Driver {    public static void main(String[] args) {        for(int i = 10; i <= 50; i+=10)        {            System.out.println("N = "+i);            System.out.println("Sum1:"+A2Work.sum1(i));            System.out.println("Sum2:"+A2Work.sum2(i));            System.out.println("Sum3:"+A2Work.sum3(i));   ...

  • help me with a question in java: class A { int i = 10; } class...

    help me with a question in java: class A { int i = 10; } class B extends A { int i = 20; } public class Boo { public static void main(String[] args) { A a = new B(); System.out.println(a.i); } }

  • Please help me with me. I did the first part to write the operations but in...

    Please help me with me. I did the first part to write the operations but in the driver its shows me errors, can't fix it. Help me. Need help with this to run the application. /** * BinaryTreeNode represents a node in a binary tree with a left and * right child. * * @author Java Foundations * @version 4.0 */ public class BinaryTreeNode { protected T element; protected BinaryTreeNode left, right; /** * Creates a new tree node with...

  • What will be the output of the following Java code? class Output { public static void...

    What will be the output of the following Java code? class Output { public static void main(String args[]) { boolean a = true; boolean b = false; boolean c = a ^ b; System.out.println(!c); } } a) 0 b) 1 c) false d) true

  • the answer must be in java. thank you Question 2 [8 points] Consider the class Class...

    the answer must be in java. thank you Question 2 [8 points] Consider the class Class A below: class Class A implements Serializable{ int a; static int b; transient int c; String s; // Constructor public Class A (int a, int b, int c, Strings){ this.a = a; this.b = b; this.c = c; this.s = s; Complete the class Test to test the serialization and deserialization of the objects of class Class A. State the possible variable values following...

  • **JAVA*JAVA Question 1 How many k's values will be printed out? public static void main(Stringl args)...

    **JAVA*JAVA Question 1 How many k's values will be printed out? public static void main(Stringl args) for (int k-1: k10:k if (k8) continue: System.out.println k) Question 2 3.5 pts Analyze the following code. Which one is correct? package p public class A package p2: import p1. public class B extends Af int i- 5 private int j- 10: public A0I public static void main(Stringll args) B b new B0: System.out.println(a.i+", "+ajt", "+b.it""+bj): a.i is printable None of them b.i is...

  • A palindrome is a word, phrase, number, or other sequence of characters which reads the same...

    A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward as forward, such as madam or racecar. Write a recursive method in java that accepts a integer as its argument and returns true if it is palindrome, false otherwise. public class Recursion {                 public static void main(String[] args) {                                 Recursion r = new Recursion();                                 System.out.println(“Is 12321 a palindrome? “+ra.isPalindrome(12321)); //true                 }                 public Boolean isPalindrome(int num){                                 return false;...

  • Need help with this Java question in 1 hour please JAVA Using the files from the...

    Need help with this Java question in 1 hour please JAVA Using the files from the in-class assignment add two additional animals of your choice. For each animal add two additional methods appropriate to your particular animal. As the majority of the code for this program exists you will not need an algorithm. Use the 3 java classes below. Thank you //Animal.java public class Animal {    public Animal() {    System.out.println("A new animal has been created!");    }   ...

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