Attachments
-
You do not have permission to view the full content of this post. Log in or register now.
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
(Inputted kilo * 35.50) - 1.775;search ka ng formula ng mag babawas ng 5% then input mo sa syntax mo
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);
Sir saan po galing yang 1.775? Hehehe sorry nalilito pako bago lang kasi sa comscie(Inputted kilo * 35.50) - 1.775;
5% = .05, 35.50 * .05 = 1.775
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:28Easy:
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);
cout << time << "seconds is "...
. Update mo din yung hour = time / 3600; minute = (time / 60) - (hour * 60); second = time - (hour * 3600) - (minute * 60).Sir nakuha ko na po pero eto mas mahirap huhuhu diko magawa try mo po silipinIlagay 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).
#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 ehEasy:
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 ibaEasy:
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
using namespace std;
Pwede alisin. Remnant lang yang ng previos code.Tsaka ano po yung #include <iomanip> di yan tinuro samin eh math.io lang alam ko na iba