What's new

Closed Pahelp naman mga sir ☹️ 3hrs nako kakacode diko makuha bago lang po ako sa c++

Status
Not open for further replies.

Ruth mae

Honorary Poster
Joined
Dec 27, 2018
Posts
390
Reaction
74
Points
194
Age
23
IMG_20190810_152952.jpg
 

Attachments

Ano hindi mo alam dito? Programming itself or the algorithm part which is basic arithmetic or both?

Care to show what you have done in that 3 hours so far (code and algorithm)?
 
Nakalimutan ko kasi sir yung computation like apple is 35.50php per kilo, ang input ko dapat If ilan bibilihin na kilo * sa price, then sir pano ko po makukuha yung 5% discount?? Yun ang diko makuha hays
Ano hindi mo alam dito? Programming itself or the algorithm part which is basic arithmetic or both?

Care to show what you have done in that 3 hours so far (code and algorithm)?
 
Nakalimutan ko kasi sir yung computation like apple is 35.50php per kilo, ang input ko dapat If ilan bibilihin na kilo * sa price, then sir pano ko po makukuha yung 5% discount?? Yun ang diko makuha hays

search ka ng formula ng mag babawas ng 5% then input mo sa syntax mo
 
Easy:
Code:
float num_kilo{0};
float price_per_kilo{35.50};
float percent_discount{0.05};
float price_before_discount = num_kilo * price_per_kilo;
float discounted_price = price_before_discount - (price_before_discount * percent_discount);
 
Easy:
Code:
float num_kilo{0};
float price_per_kilo{35.50};
float percent_discount{0.05};
float price_before_discount = num_kilo * price_per_kilo;
float discounted_price = price_before_discount - (price_before_discount * percent_discount);
Woww 🙂 wait try ko to sir sana mapagana ko naa, btw may isa pakong proj nakuha ko na pero may isabaoong di makuha baka pede paturo hehehe like mag input ng num of seconds like 6500 seconds dapat ang output po 6500 seconds is 1:48:20, pano ko po makukuha at malalagay yang ininput ko na 6500 sa unahan lumalabas lang kasi saken seconds is 1:48:28
 
Di ako pamilyar sa syntax sa c pero need mo tawagin or lagay yung variable na naglalaman ng seconds.
Ex.
float seconds; //variable na pang sapo
sa input
float converted; //var na pang seconds to hr
Pag print mo parang ganto seconds + seconds is: + converted
 
Di ako pamilyar sa syntax sa c pero need mo tawagin or lagay yung variable na naglalaman ng seconds.
Ex.
float seconds; //variable na pang sapo
sa input
float converted; //var na pang seconds to hr
Pag print mo parang ganto seconds + seconds is: + converted
 
Ilagay mo sa ibang variable yung value ng number of seconds, sa time mo na lang ilagay tapos include mo sa output yung time na variable sa unahan. cout << time << "seconds is ".... Update mo din yung hour = time / 3600; minute = (time / 60) - (hour * 60); second = time - (hour * 3600) - (minute * 60).
 
Last edited:
Sawa
Ilagay mo sa ibang variable yung value ng number of seconds, sa time mo na lang ilagay tapos include mo sa output yung time na variable sa unahan. cout << time << "seconds is ".... Update mo din yung hour = time / 3600; minute = (time / 60) % 60; second = time - (hour * 3600) - (minute * 60).
Sir nakuha ko na po pero eto mas mahirap huhuhu diko magawa try mo po silipin
 

Attachments

Easy:
Code:
#include <iomanip>
#include <iostream>

int main(int argc, char *argv[]) {
    float price_per_kilo {35.50};
    float num_kilo{-1};
    float discount{00.05};
    std::cout.setf(std::ios::fixed, std::ios::floatfield);
    std::cout.setf(std::ios::showpoint);
    std::cout.precision(2);
    std::cout << "\n\n+---------------------------------------------------------+" << std::endl;
    std::cout << "| CURRENT price of mango/kg: " << price_per_kilo << " -- " << "less " << discount*100 << "% discount |" << std::endl;
    std::cout << "+---------------------------------------------------------+" << std::endl;
    std::cout << "How many kilos of mangoes would you like to buy: " << std::flush;
    std::cin >> num_kilo;
    while (num_kilo != 0) {
        float total_price = num_kilo*price_per_kilo;
        float discounted_price = total_price-(total_price*discount);
        std::cout << "Total price BEFORE discount: " << total_price << std::endl;
        std::cout << "Amount discounted: " << total_price*discount << std::endl;
        std::cout << "Discounted price: " << discounted_price << "\n" << std::endl;
        std::cout << "Shop more? Enter '0' (or CTRL-c) to quit." << std::endl;
        std::cout << "How many kilos of mangoes would you like to buy: " << std::flush;
        std::cin >> num_kilo;
    }
    std::cout.unsetf(std::ios::fixed);
    std::cout << "\nThank you for shopping with us!\n" << std::endl;
    return 0;
}
 
Easy:
Code:
#include <iomanip>
#include <iostream>

int main(int argc, char *argv[]) {
    float price_per_kilo {35.50};
    float num_kilo{-1};
    float discount{00.05};
    std::cout.setf(std::ios::fixed, std::ios::floatfield);
    std::cout.setf(std::ios::showpoint);
    std::cout.precision(2);
    std::cout << "\n\n+---------------------------------------------------------+" << std::endl;
    std::cout << "| CURRENT price of mango/kg: " << price_per_kilo << " -- " << "less " << discount*100 << "% discount |" << std::endl;
    std::cout << "+---------------------------------------------------------+" << std::endl;
    std::cout << "How many kilos of mangoes would you like to buy: " << std::flush;
    std::cin >> num_kilo;
    while (num_kilo != 0) {
        float total_price = num_kilo*price_per_kilo;
        float discounted_price = total_price-(total_price*discount);
        std::cout << "Total price BEFORE discount: " << total_price << std::endl;
        std::cout << "Amount discounted: " << total_price*discount << std::endl;
        std::cout << "Discounted price: " << discounted_price << "\n" << std::endl;
        std::cout << "Shop more? Enter '0' (or CTRL-c) to quit." << std::endl;
        std::cout << "How many kilos of mangoes would you like to buy: " << std::flush;
        std::cin >> num_kilo;
    }
    std::cout.unsetf(std::ios::fixed);
    std::cout << "\nThank you for shopping with us!\n" << std::endl;
    return 0;
}
Sir pede po ba alisin ko yang mga std:: sa COUT?? Di kasi yan tinuro samin eh
 
Easy:
Code:
#include <iomanip>
#include <iostream>

int main(int argc, char *argv[]) {
    float price_per_kilo {35.50};
    float num_kilo{-1};
    float discount{00.05};
    std::cout.setf(std::ios::fixed, std::ios::floatfield);
    std::cout.setf(std::ios::showpoint);
    std::cout.precision(2);
    std::cout << "\n\n+---------------------------------------------------------+" << std::endl;
    std::cout << "| CURRENT price of mango/kg: " << price_per_kilo << " -- " << "less " << discount*100 << "% discount |" << std::endl;
    std::cout << "+---------------------------------------------------------+" << std::endl;
    std::cout << "How many kilos of mangoes would you like to buy: " << std::flush;
    std::cin >> num_kilo;
    while (num_kilo != 0) {
        float total_price = num_kilo*price_per_kilo;
        float discounted_price = total_price-(total_price*discount);
        std::cout << "Total price BEFORE discount: " << total_price << std::endl;
        std::cout << "Amount discounted: " << total_price*discount << std::endl;
        std::cout << "Discounted price: " << discounted_price << "\n" << std::endl;
        std::cout << "Shop more? Enter '0' (or CTRL-c) to quit." << std::endl;
        std::cout << "How many kilos of mangoes would you like to buy: " << std::flush;
        std::cin >> num_kilo;
    }
    std::cout.unsetf(std::ios::fixed);
    std::cout << "\nThank you for shopping with us!\n" << std::endl;
    return 0;
}
Tsaka ano po yung #include <iomanip> di yan tinuro samin eh math.io lang alam ko na iba
 
Status
Not open for further replies.
Back
Top