a. Design a class to hold a JobBid. Each JobBid contains a bid number and a quot
ID: 654590 • Letter: A
Question
a. Design a class to hold a JobBid. Each JobBid contains a bid number and a quoted price.
Each JobBid also contains overloaded extraction and insertion operators.
b. Include an overloaded operator<()function. A JobBid is considered lower than another
JobBid when the quoted price is lower.
c. Write a main()function that declares an array of four JobBid objects. Find and display
the lowest JobBid. Save the file as JobBid.cpp.
I found this online but there is no main function and there's a lot of misspellings. Can anyone help this is due in 7 hours?
class Jobid {
public:
Jobid(int initBid, int intiQuote ) {
if (intBid < 0)
initBid *= -1; // make a negative bid positve
if (initQuote < 0)
initQoute *= -1; // same as above
bid = initBid; // store them
qoute = initQoute;
}
bool operator < (const Jobid& j) const { return qoute < j.qoute; }
int Bid() { return bid; }
int Qoute { return qoute; }
private:
int bid;
int qoute;
};
//<<
osteam& operator << (ostream& out, const JobBid& j) {
out << (output whatever here. use Bid() and Qoute() )
return out;
}
Explanation / Answer
// JobBid.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "stdio.h"
#include "conio.h"
#include "iostream"
using namespace std;
class JobBid {
private:
int bid;
int qoute;
public:
JobBid(int initBid, int initQuote )
{
if (initBid < 0)
initBid *= -1; // make a negative bid positve
if (initQuote < 0)
initQuote *= -1; // same as above
bid = initBid; // store them
qoute = initQuote;
}
bool operator < (const JobBid& j) const { return qoute < j.qoute; }
int Bid() { return bid; }
int Qoute() { return qoute; }
};
//<<
/*ostream& operator << (ostream& out, const JobBid& j)
{
out << (output whatever here. use Bid() and Qoute() )
return out;
}*/
void main()
{
JobBid jbid[4] = {JobBid(1,3000),JobBid(2,2700),JobBid(3,3500),JobBid(4,2900)};
JobBid minbid = jbid[0];
for(int i=1;i<4;i++)
{
if(jbid[i] < minbid)
minbid = jbid[i];
}
cout << "The lowest bid is bid number : " << minbid.Bid() << ", quote : " << minbid.Qoute();
_getch();
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.