c++
5.(10) a. Now define an array of type TVSpecs to hold 50 TVs and name the array TVShoppe.
(10) b. Write the code to count how many TVs in the array TVShoppe that are with smart remotes and are priced less than $1,000.
ANSWER : HERE IS THE ANSWER FOR YOUR QUESTION:
----------------------------------------------------------------------------------------------------------------
CODE:
#include <iostream>
using namespace std;
// defining the structure for the TVSpecs structure
struct TVSpecs
{
//screen_size as integer variable
int screen_size;
// string type variable as remote_type to hold data
string remote_type;
// float data type for storing the TV_price
float TV_price;
};
int main()
{
// 5(a) --> declaring the array TVShoppe of size 50 of type
TVSpecs
TVSpecs TVShoppe[50];
// 5(b)
int count=0;
for(int i=0;i<50;i++)
{
if(TVShoppe[i].remote_type=="smart" && TVShoppe[i].TV_price
<=1000 )
{
count++;
}
}
}
----------------------------------------------------------------------------------------------------------------
SNIPPET:
----------------------------------------------------------------------------------------------------------------
OUTPUT:
----------------------------------------------------------------------------------------------------------------
I hope this would help you out.
If you like my answer , please upvote
If you have any doubt, you can provide comment /feedback below the answer
Thanks
Get Answers For Free
Most questions answered within 1 hours.