Quick actions

cmd+k|ctrl+k

Navigation

Languages

Vanishing night

Snippet info

Language

Cpp

Visibility

public

Author

kaniaslan27

Created

2024-05-01T19:00:31.591109Z

Updated

2024-05-01T19:00:31.591109Z

#include <iostream>
int main(){
    //this part is asking for the times in Mecka from ma to s respectively
    double a1_1, c1_1, d1_1;
    std::cout << "What is the time for maghrib in mecka" << '\n';
    std::cin >> a1_1;
    std::cout << "What is the time for fajr in Mecka" << '\n';
    std::cin >> c1_1;
    std::cout << "What is the time for shuruq in Mecka" << '\n';
    std::cin >> d1_1;

    //Asking for the times of ma and s only from the city the person is currently at
    double a1_2, d1_2;
    std::cout << "What is the time for maghrib in your prefered location" << '\n';
    std::cin >> a1_2;
    std::cout << "What is the time for shuruq in your wanted location" << '\n';
    std::cin >> d1_2;

    //Calculating how many minutes there are for each prayer in Mecka
    int a2_1 = (int( a1_1 * 100)) % 100 + (int(a1_1))*60;
    int c2_1 = (int( c1_1 * 100)) % 100 + (int(c1_1))*60 + 60 * 24 ;
    int d2_1 = (int( d1_1 * 100)) % 100 + (int(d1_1))*60 + 60 * 24;

    //calculating how many minutes there are for each time in designated location
    int a2_2 = (int( a1_2 * 100)) % 100 + (int(a1_2))*60;
    int d2_2 = (int( d1_2 * 100)) % 100 + (int(d1_2))*60 + 60 * 24;

    //calculating how many minutes there are from the time of maghrib in Mecka
    int c3_1 = c2_1 - a2_1;
    int d3_1 = d2_1 - a2_1;

    //calculating how many minutes until shuruq in designated location
    int d3_2 = d2_2 - a2_2;

    //Calculating how many minutes from maghrib until first third of the night enters
    int e4_1 = int(c3_1 /3);

    //calculating how many percentage of the time between maghrib and shuruq until first third of the night ends in Mecka
    double f5_1 = double(e4_1) / double(d3_1);

    //applying the percentage in mecka to the nordic countries
    double g6_2 = double(d3_2) * double(f5_1);

    //calculate how many minutes until the third of the night starts
    int g7_2 = g6_2 + a2_2;

    //calculating how many hours there are until it starts
    double g8_2 = (int(g7_2/60)) + (double((g7_2)%60))/100;

    if (g8_2 > 24)
    {
        g8_2 -= 24;
    }
    std::cout << "The time of the first third of the nigt ends at: " << g8_2; 
}
INFO