Symbianize Forum

Most of our features and services are available only to members, so we encourage you to login or register a new account. Registration is free, fast and simple. You only need to provide a valid email. Being a member you'll gain access to all member forums and features, post a message to ask question or provide answer, and share or find resources related to mobile phones, tablets, computers, game consoles, and multimedia.

All that and more, so what are you waiting for, click the register button and join us now! Ito ang website na ginawa ng pinoy para sa pinoy!

Please Help Me "Java, Looping statement"

mirana22

Recruit
Basic Member
Messages
18
Reaction score
0
Points
16
View attachment 258396
Please Help po... hindi ko po kasi maintindihan kung pano makukuha ung sa coin...
Yung Output po ganto po..​

Total Purchase : 100
Cash : 225

*************************
10 Peso Coins : (12)
5 Peso Coins : (1)
1 Peso Coin : (0)
25 Cents : (0)
10 Cents : (0)
5 Cents : (0)
Change : 125

Please tulungan nyo po ako... Maraming salamat po​
 

Attachments

  • 12742303_1106036059447766_2887107083267212140_n.jpg
    12742303_1106036059447766_2887107083267212140_n.jpg
    77.6 KB · Views: 31
for cash>0 then
cash-1
(tapos iwan kuna)

hehehehe sana may makatulong sayo
 
View attachment 1104777
Please Help po... hindi ko po kasi maintindihan kung pano makukuha ung sa coin...
Yung Output po ganto po..​

Total Purchase : 100
Cash : 225

*************************
10 Peso Coins : (12)
5 Peso Coins : (1)
1 Peso Coin : (0)
25 Cents : (0)
10 Cents : (0)
5 Cents : (0)
Change : 125

Please tulungan nyo po ako... Maraming salamat po​

Sana Makatulong TS

import java.util.*;
public class Main
{
static Scanner input = new Scanner(System.in);
public static void main()
{
System.out.print("\f");
System.out.print("Total Purchase: \t");
double total=input.nextDouble();
System.out.print("Cash: \t\t\t");
double cash=input.nextDouble();

double Change = cash-total;
int Change2=(int)(cash-total);
int Ten = (int)(Change/10);
int Five = (int)(Change%10)/5;
int One = (int)(Change%10%5)/1;
int CentsValue=(int)((Change-Change2)*100);
int TwentyFiveCents= CentsValue/25;
int TenCents = (CentsValue%25)/10;
int FiveCents = (CentsValue%25%10)/5;
System.out.print("\n***************************************");
System.out.print("\nTen Peso Coins: \t"+Ten+"\nFive Peso Coins: \t"+Five+"\nOne Peso Coins: \t"+One+"\nTwenty Five Cents: \t"+TwentyFiveCents+"\nTen Cents: \t\t"+TenCents+"\nFive Cents: \t\t"+FiveCents);
System.out.printf("\nChange: \t\t%.2f",Change);
}
}
 
Sana Makatulong TS

sir salamat po ng madami... pero pano po sya pag looping statement ang gagamitin?? looping statement po kasi topic namin ngayon... maraming salamat po sir....
 
Use Do While ts

Sir pwede nyo po ba ituro sa akin ung format kung pano? Hindi ko po kasi maintindihan...

Ung sa do while po ba? Pwedeng kahit wala na pong increment/decrement? Salamat po sir...
 
Sir pwede nyo po ba ituro sa akin ung format kung pano? Hindi ko po kasi maintindihan...

Ung sa do while po ba? Pwedeng kahit wala na pong increment/decrement? Salamat po sir...
na solve mo na ba do while? looping?

i guees bawal dito spoon feeding.. search mo lang sa utube php syntax..
 
Last edited:
wala na ako masabi sa mga thread starters ngayon... yung "assignment" nya, pincturan na lang, yung solution pa mismo ang hinihingi... anong klaseng katamaran na ang natututunan ngayon?
 
wala na ako masabi sa mga thread starters ngayon... yung "assignment" nya, pincturan na lang, yung solution pa mismo ang hinihingi... anong klaseng katamaran na ang natututunan ngayon?

yan yung mga taong hindi makakahanap ng trabaho tapos sisihin ang prof/instructor kasi di nagtuturo
 
View attachment 1104777
Please Help po... hindi ko po kasi maintindihan kung pano makukuha ung sa coin...
Yung Output po ganto po..​

Total Purchase : 100
Cash : 225

*************************
10 Peso Coins : (12)
5 Peso Coins : (1)
1 Peso Coin : (0)
25 Cents : (0)
10 Cents : (0)
5 Cents : (0)
Change : 125

Please tulungan nyo po ako... Maraming salamat po​

Try lng TS, ikaw na bahalang magtuloy :)

while (change != 0) {
if (change >= 10) {
tenPeso = (int) (change/10);
change = change%10;
} else if(change >= 5){
fivePeso = (int) (change/5);
change = change%5;
} else if(change >= 1){
onePeso = (int) (change/1);
change = change%1;
} else if(change >= 0.25){
twentyFiveCents = (int) (change/0.25);
change = change%0.25;
} else if(change >= 0.1){
tenCents = (int) (change/0.1);
change = change%0.1;
} else if(change >= 0.05){
fiveCents = (int) (change/0.05);
change = 0;
}
}
 
Back
Top Bottom