
ANSWER:
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
int main()
{
float days,angle,magnitude; //variables for storing number of days,
the angle used in cosine and magnitude of brightness
cout<<"Enter the number of days: "; //Prompting the user to
enter the number of days
cin>>days; //User entering the number of days
while(days<0.0) //if user enters a negative value
{ //Prompting him to enter the value again
cout<<"Enter a number greater than 0: ";
cin>>days;
}
float days2=fmod(days,6.4); //variable to store days%6.4 as cycle
is of 6.4 days
if(days2<0.9) //If days are from 0 to 0.9
{
magnitude=2.5; //then magnitude = 2.5
}
else if(days2<2.3) //If days are from 0.9 to 2.3
{
angle=3.14*(days-0.9); //calculating angle to be used in
cosine
angle=angle/0.7;
magnitude=3.355-(log(1.352+cos(angle))); //formula for
magnitude
}
else if(days2<4.4) //If days are from 2.3 to 4.4
{
magnitude=2.5; //then magnitude is 2.5
}
else if(days2<5.2) //If days are from 4.4 to 5.2
{
angle=3.14*(days-4.4); //calculating angle to be used in
cosine
angle=angle/0.4;
magnitude=3.598-(log(1.998+cos(angle))); //formula for
magnitude
}
else //If days are from 5.2 to 6.4
{
magnitude=2.5; //then magnitude is 2.5
}
cout<<"At ";
cout<<setprecision(3)<<days; //setting precision of
days to 3
cout<<" days the magnitude of the binary star is ";
cout<<setprecision(5)<<magnitude<<endl; //setting
precision of magnitude to 5
return 0;
}
Output

the language is c++ Goals: Developing problem-solving skills, declaring variables, multi-way branches, data valida...