//Basic to class
#include <iostream.h>
#include <conio.h>
class date
{
int day, month, year;
public:
date()
{
day = month = year = 0;
}
date(int tal_day)
{
year = tal_day / 365;
tal_day = tal_day % 365;
month = tal_day / 30;
day = tal_day % 30;
}
void display()
{
cout << endl << "year = " << year;
cout << endl << "month = " << month;
cout << endl << "day = " << day;
}
};
void main()
{
int tal_day;
clrscr();
cout << "Enter Total Days = ";
cin >> tal_day;
date obj;
obj = tal_day;
obj.display();
getch();
}
7.Write a program to read a list containing item name, item code and cost interactively and produce a three-column output as shown below. NAME CODE COST Turbo C++ 1001 250.95 C Primer 905 95.70 ------------- ------- ---------- ------------- ------- ---------- Note that the name and code are left-justified and the cost is right-justified with a precision of two digits. Trailing zeros are shown.
/*J_4_P_8 Write a program to read a list containing item name, item code and cost interactively and produce a three-column output as shown below. NAME CODE COST ======================= Turbo C++ 1001 250.95 C Primer 905 95.70 ------------- ------- ----------------- ------------- ------- ----------------- Note that the name and code are left-justified and the cost is right-justified with a precision of two digits. Trailing zeros are shown. */ #include <iostream.h> #include <iomanip.h> #include <string.h> #include <conio.h> class item { char name[40]; int code; float cost; public: void get_data(char *n, int c, float co)...
Comments
Post a Comment