Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
anushka23g authored Jan 22, 2021
2 parents b37d838 + 9a5749a commit 5559a83
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 25 deletions.
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,21 @@ Once you have completed these steps, you are ready to start contributing by chec
<br>
### 6️⃣ Running the work on your local machine :computer:
To run the code and play with the app on your local machine, do:
* `if os == 'Windows'`:
* We have tested the code in **Dev C++ IDE** and **Code Blocks IDE** **(Both running MINGW)**.
* To run the code in any IDE, simply open the file, click `Execute > Run` [Click here for more instructions](http://cs.uno.edu/~jaime/Courses/2025/devCpp2025Instructions.html)
* `if os == 'Linux or Unix or Mac'`:
* You need to have `GCC` installed:
* Go to the folder having the code(.cpp file).
* Open the terminal, and type : `g++ -o test_prep test-prep.cpp`
* Then run the script by typing : `./test_prep`
<br>
### 6️⃣ Create a new branch :bangbang:
### 7️⃣ Create a new branch :bangbang:
Whenever you are going to make contribution. Please create seperate branch using command and keep your `master` branch clean (i.e. synced with remote branch).
Expand Down Expand Up @@ -171,7 +183,7 @@ $ git commit -m 'relevant message'
<br>
### 7️⃣ Share your work :star_struck:
### 8️⃣ Share your work :star_struck:
Now, Push your awesome work to your remote repository using
Expand Down
73 changes: 50 additions & 23 deletions test-prep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ void printJobScheduling(subject arr[], int n)
{

sort(arr, arr+n, comparison);


for (int i=0;i<n;i++) {
cout<<"\n"<<i+1<<") "<<arr[i].sname; // updated the function and it works correctly now( error RTE before user feedback() )
}
Expand Down Expand Up @@ -117,6 +119,41 @@ void printJobScheduling(subject arr[], int n)
// { cout <<i;
// cout << arr[result[i]].sname << "\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 << arr[result[i]].sname << "\n";
}
}

}


Expand Down Expand Up @@ -180,12 +217,8 @@ void user_feedback(){


/*
end
COMPLETE FOR 1 SUBJECT
*/


Expand Down Expand Up @@ -321,53 +354,48 @@ int main()
}
int date;

cout << "Enter today's date (Format: dd):\n ";
cout << "Enter today's date (Format: dd): ";
cin >> date;
int month;
cout<<"Enter the month (Format: mm):\n";

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

int tgive;

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

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

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

cin >> s[i].examdate;
cout << "enter month: ";
cin>>s[i].exam_month;

s[i].time_left = s[i].examdate - date + 1; //// changed the -1 to +1 for resolving error (RTE)

cout << "\n enter month: ";
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;
}

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;
}
}

}

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";

int timp = 0;
Expand All @@ -376,16 +404,15 @@ int main()
{
cout << s[i].sname << ": ";
cin >> s[i].prep;
s[i].imp = s[i].credits / ((s[i].prep) * (s[i].time_left));
s[i].imp = s[i].credits*ttime / ((s[i].prep) * (s[i].time_left)); // calculating importance of each subject
s[i].profit = s[i].credits / s[i].prep;
timp += s[i].imp;

s[i].stime = s[i].credits * ttime / s[i].prep;

//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";

printJobScheduling(s, n);
}
Expand Down

0 comments on commit 5559a83

Please sign in to comment.