PS: Imagine you are the salesperson in the supermarket and arranging the apples based on their size (in kgms) every day. One fine day, you decided to scan all the apples size and arrange it in less time than ever before. The scanner measured the apple’s size, for example, Apple 1 = 1.4 kgms and 1 kgms, Apple 2 = 1.8 kgms and 2 kgms. This made you arrange two patterns: Pattern 1 – apple size measured in float, Pattern 2 – apple size measured in integer. Design a C++ program to implement this given use case?
#include<iostream>
using namespace std;
int main(){
int number;
cout<<"Enter the number of apples\n";
cin>>number;
float pattern_1[number];
int pattern_2[number];
cout<<"Enter the apples' sizes \n";
for(int i = 0; i<number; i++){
cout<<"Apple "<<(i+1);
cout<<"\nSize in float\n";
cin>>pattern_1[i];
cout<<"\nSize in integer\n";
cin>>pattern_2[i];
}
cout<<"The apples' sizes are as below\n";
cout<<"Apple "<<" Size in float "<<" Size in integer\n";
for(int i=0; i<number; i++){
cout<<(i+1)<<"\t\t"<<pattern_1[i]<<" kgms\t\t"<<pattern_2[i]<<" kgms"<<endl;
}
}
Comments
Leave a comment