Skip to content

Commit

Permalink
Added beautifying features
Browse files Browse the repository at this point in the history
  • Loading branch information
sagnik1511 authored Jan 24, 2021
1 parent 5559a83 commit 28bb6c3
Showing 1 changed file with 70 additions and 75 deletions.
145 changes: 70 additions & 75 deletions test-prep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,38 +88,6 @@ void printJobScheduling(subject arr[], int n)
cout<<"\n"<<i+1<<") "<<arr[i].sname; // updated the function and it works correctly now( error RTE before user feedback() )
}
cout<<"\n";
// int result[n];
// bool slot[n];
//
//
// for (int i=0; i<n; i++)
// slot[i] = false;
//
//
// for (int i=0; i<n; i++)
// {
//
//
// for (int j=min(n, arr[i].time_left)-1; j>=0; j--)
// {
//
// if (slot[j]==false)
// {
// result[j] = i; // Add this job to result
// slot[j] = true; // Make this slot occupied
// break;
// }
// }
// }
//
//
// for (int i=n-1; i>=0; i--)
// {
// if (slot[i])
// { cout <<i;
// cout << arr[result[i]].sname << "\n";}
// }
=======

int result[n];
bool slot[n];
Expand Down Expand Up @@ -174,21 +142,23 @@ double fractionalKnapsack(float W, topic arr[], int n)
finalvalue += arr[i].weightage;
if(arr[i].count==0)
{
cout<<arr[i].name;
cout<<arr[i].name<<" ";


}
cout<<"\n";
if(arr[i].count==1)
{
float trev=arr[i].time/2;
float tpaper=arr[i].time/4;
float tdoubts=arr[i].time/4;

cout<<"You can revise the topic"<<arr[i].name<< "in "<<trev<<" hours"<<"\n";
cout<<"You can revise the topic " <<arr[i].name<< " in "<<trev<<" hours"<<"\n";

cout<<"Do not forget to take a look at last year questions for this topic in the next"<<tpaper<<" hours"<<"\n";
cout<<"Do not forget to take a look at last year questions for this topic in the next "<<tpaper<<" hours"<<"\n";

cout<<"try to clear your doubts about this topic in next"<<tdoubts<<" hours"<<"\n";cout<<"\n";
cout<<"Try to clear your doubts about this topic in next "<<tdoubts<<" hours"<<"\n";cout<<"\n";
cout<<"--------------------------------------------------------\n";

}
}
Expand All @@ -197,7 +167,7 @@ double fractionalKnapsack(float W, topic arr[], int n)
{
int remain = W - curMarks;
finalvalue += arr[i].weightage * ((double) remain / arr[i].time);
cout<<"You can only do some part of the chapter";
cout<<"You can only do some part of the chapter ";
break;
}
if(curMarks>=W){return 0.0;}
Expand Down Expand Up @@ -239,19 +209,20 @@ int main()
int n;
cout << "Enter the no. of topics: ";
cin >> n;

cout<<"--------------------------------------------------------\n";
int total_diff = 0; // sp

topic t[2 * n];

cout << "Enter name of each topic: ";
cout << "Enter name of each topic: \n";

for (int i = 0; i < n; i++)
{
cout<<i+1<<") ";
cin >> t[i].name;
}

cout << "Enter priority of each topic i.e. expected weightage: ";
cout << "--------------------------------------------------------\nEnter priority of each topic i.e. expected weightage: \n";

for (int i = 0; i < n; i++)
{
Expand All @@ -262,7 +233,8 @@ int main()
t[i].count = 0;
}

cout << "Enter difficulty level of each topic based on your own understanding from(1-10) 1 being the easiest: ";
cout << "--------------------------------------------------------\n";
cout<<"Enter difficulty level of each topic based on your own understanding from(1-10) 1 being the easiest: \n";

for (int i = 0; i < n; i++)
{
Expand All @@ -275,37 +247,48 @@ int main()

float total_time; // tt
float focused_time; // eff
cout << "Enter total time available to study this subject in hours: ";
cout << "--------------------------------------------------------\nEnter total time available to study this subject in hours: ";
cin >> total_time;

cout << "How much you can resist yourself from using phone during exams?(1-10): ";
cout << "--------------------------------------------------------\nHow much you can resist yourself from using phone during exams?(1-10): ";
cin >> focused_time;


cout<<"\n--------------------------------------------------------\n";

float available_time = total_time * focused_time / 10; //at
cout << "Allotted time: " << available_time << "\n";
cout << "Difficulty Level: " << total_diff << "\n";
float utilised_val = available_time / total_diff; //ut
cout << "Utilization Time: " << utilised_val << "\n";


cout<<"--------------------------------------------------------\n";

for (int i = 0; i < n; i++)
{
t[i].time = utilised_val * t[i].difficulty / 10;
cout << t[i].name << " " << t[i].time * 10 << "\n";
cout << t[i].name << " ---> " << t[i].time * 10 << "\n";
}


cout<<"--------------------------------------------------------\n";

int checksub;
cout << "The time is: ";
cout << "Please check if you will be able to complete the topics in the given time \nIf okay press 1 else press 0: ";
cout << "The time is: \n";

for (int i = 0; i < n; i++)
{
cout << t[i].name << " " << t[i].time << "\n";
cout << t[i].name << " ---> " << t[i].time << "\n";
}


cout<<"\n--------------------------------------------------------\n";

cout << "Please check if you will be able to complete the topics in the given time \nIf okay press 1 else press 0: ";
cin >> checksub;


cout<<"\n--------------------------------------------------------\n";

if (checksub == 0)
{
cout << "You can enter the time manually: ";
cout << "You can enter the time manually: \n";
for (int i = 0; i < n; i++)
{
cin >> t[i].time;
Expand All @@ -330,8 +313,8 @@ int main()

double prepared = fractionalKnapsack(available_time, t, 2 * n);

cout << prepared;
return 0;
cout << prepared<<"\n--------------------------------------------------------\n";
//return 0;
}

else if (option == 0)
Expand All @@ -345,56 +328,62 @@ int main()
subject s[n];
int tcred = 0;

cout << "Enter name and credits for each subject: ";
cout << "Enter name and credits for each subject: \nPrint the name and the credits separating with a space \n";
cout<<"--------------------------------------------------------\n";
for (int i = 0; i < n; i++)
{

cout<< i+1<<") ";
cin >> s[i].sname >> s[i].credits;
tcred += s[i].credits;
}
int date;

cout << "Enter today's date (Format: dd): ";
cout << "--------------------------------------------------------\nEnter today's date (Format: dd): ";
cin >> date;
int month;

cout<<"Enter the month (Format: mm): ";
cin>>month;

int tgive;

cout << "How much time can you give each day to studies(in hours): ";
cout << "--------------------------------------------------------\nHow much time can you give each day to studies(in hours): ";
cin >> tgive;

cout << "Enter the date and month for the following exams: \n";
cout << "--------------------------------------------------------\nEnter the date and month for the following exams: \n\n";

for (int i = 0; i < n; i++)
{
cout << s[i].sname << ":\nenter date: ";

//cout << s[i].sname << ":\nenter date: \n";
cout<< "Date of the exam for subject "<<s[i].sname<<": ";
cin >> s[i].examdate;
cout << "enter month: ";
// cout << "\nenter month: ";
cout<< "Month of the exam for subject "<<s[i].sname<<": ";
cin>>s[i].exam_month;


if(s[i].exam_month==month){//calculating the time left if the exam is on the same month as the date
s[i].time_left=s[i].examdate-date+1;
cout<<"time left:"<<" "<<s[i].time_left<<" days"<<endl;
//cout<<"time left:"<<" "<<s[i].time_left<<" days"<<endl;
}

else if(s[i].exam_month>month){//calculating the time left if the exam is scheduled in later months
if(s[i].examdate>date){
int month_value=s[i].exam_month-month;
s[i].time_left = month_value*(30+abs(s[i].examdate - date + 1));
cout<<"time left: "<<s[i].time_left<<" days"<<endl;

}
else{
s[i].time_left=30-date+s[i].examdate+1;
cout<<"time left: "<<s[i].time_left<<" days"<<endl;
//cout<<"time left: "<<s[i].time_left<<" days"<<endl;
}
}
}

cout<<"--------------------------------------------------------\n";
for (int i=0 ; i<n ; i++ )
{
cout<<"time left for "<<s[i].sname<<" subject : "<<s[i].time_left<<" days"<<endl;
}
cout<<"--------------------------------------------------------\n";
int ttime = s[0].time_left * tgive;
cout << "How much previous preparation do you have on a scale of 1 to 10? \n10 being highest and 1 being the lowest: \n";

Expand All @@ -412,9 +401,10 @@ int main()

//cout<<s[i].sname<<" "<<s[i].credits<<" "<<s[i].profit<<" "<<s[i].stime<<" "<<s[i].prep<<" "<<s[i].time_left<<endl;
}
cout << "Complete the subjects in the following sequence to maximize your percentage:\n";
cout << "Complete the subjects in the following sequence to maximize your percentage:\n--------------------------------------------------------\n";

printJobScheduling(s, n);
cout<<"--------------------------------------------------------\n";
}

//mixed scheduling of all subjects
Expand All @@ -433,11 +423,11 @@ int main()
subject s[n];

int ttopic = 0;
cout << "Enter name of the subject,credits and no. of topics in each subject: ";
cout << "--------------------------------------------------------\nEnter name of the subject,credits and no. of topics in each subject: \n";

for (int i = 0; i < n; i++)
{

cout<<i+1<<") ";
cin >> s[i].sname >> s[i].credits >> s[i].topics;
ttopic += s[i].topics;
}
Expand All @@ -460,23 +450,27 @@ int main()
for (int i = 0; i < n; i++)
{

cout << "Enter name of each topic with its weightage in exam and difficulty level for you (from 1-10 \n 1 being the easiest) for the subject\n ";
cout << "Enter name of each topic with its weightage in exam and difficulty level for you \n(from 1-10 1 being the easiest) for the subject\n\n ";

cout << s[i].sname << ": ";
cout << s[i].sname << ": \n";

for (int j = 0; j < s[i].topics; j++)
{
cout<<"Topic "<<j+1<<") ";
cin >> it[y].name >> it[y].weightage >> it[y].difficulty;

it[y].imp = it[y].weightage * s[i].credits * it[y].difficulty;

y++;
}
cout<<"\n--------------------------------------------------------\n";
}




cout << "Do you want to do major chapters first ( press 1 ) or the most difficult ones (press 0)? ";
cin >> ask;

cout<<"--------------------------------------------------------\n";
if (ask == 0)
{

Expand Down Expand Up @@ -504,6 +498,7 @@ int main()
cout << it[i].name << "\n";
}
}
cout<<"--------------------------------------------------------\n";
}
user_feedback();
return 0;
Expand Down

0 comments on commit 28bb6c3

Please sign in to comment.