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!

All about programming (Specially c, c++, VB, Java)

Good day po.. question po para san po yung i = i * 10 dito sa code na to... dec to binary d ko po kc magets kung para san yun e

int dec,rem,i=1,sum=0;

cin>>dec;

do
{
rem=dec%2;
sum=sum + (i*rem);
dec=dec/2;
i=i*10; //para san po ito?

}while(dec>0);

cout<<sum;
 
@EasyCure

Ang gamit nyan eh para mai-move yung current position from right to left sa binary by one digit.
Example:
Decimal = 5
Binary = 101
1 = 1st loop (i=1)
01 = 2nd loop (i=10)
101 = 3rd loop (i=100)
 
Sir pa help nmn po iprogram to.

file name: Clock.java

Time of the Day ---------- Part of the Day
8:01 - 12:00 -------------- Morning
12:01 - 17:00 -------------- Afternoon
17:01 - 24:00 -------------- Evening
00:01 - 8:00 --------------- Early Morning


Example Output:

Time of the Day ------------ Part of the Day
00:01 - 08:00 --------------- Early Morning



sir pahelp po sa code tska panu po madeclare ung min as "00". for example po kc int min = 09, output nya po ay 9 lang.. pa help po. beginner lang kc..
tnx in advance po :D

Java 8 is powerful enough to get this done in a blink of an eye. lol ~ just kidding

Have a look at this:
Code:
        //import java.time.LocalTime;

        Integer hr = 8;
        Integer min = 0;
        
        LocalTime inputTime = LocalTime.of(hr, min);
        
        if (inputTime.isAfter(LocalTime.of(0, 0)) && inputTime.isBefore(LocalTime.of(8, 1)))
            System.out.println("Early Morning");
        else if (inputTime.isAfter(LocalTime.of(8, 0)) && inputTime.isBefore(LocalTime.of(12, 1)))
            System.out.println("Morning");
        else if (inputTime.isAfter(LocalTime.of(12, 0)) && inputTime.isBefore(LocalTime.of(17, 1)))
            System.out.println("Afternoon");
        //...//
 
Last edited:
@EasyCure

Ang gamit nyan eh para mai-move yung current position from right to left sa binary by one digit.
Example:
Decimal = 5
Binary = 101
1 = 1st loop (i=1)
01 = 2nd loop (i=10)
101 = 3rd loop (i=100)

ah.. thanks po sir ! :)
 
Sino mga android developers dito.. Pwede ba na maging studyante nyo ako? :)
Java language ko at mag start plang ako sa android ngaun..

MENTOR PLEASE :praise:
 
Ts pahelp

about c++ binary predicate to

Panu kung meron akong binary predicate na ganito


Code:
 bool Generic_algorithm::isShort( const string &s1, const  string &s2){
	return s1.size() < s2.size();
	
}

tpos tinawag ko xa sa main
Code:
int main(){
vector<string>words{"hi","hello","hey"};
	 stable_sort(words.begin(), words.end(), isShort);	// using the predicate
}

ang problema di ko maintidihan kung paanu kumukuha ng argument ung isShort()

Kpag kinuha nya na argument ung unang string sa words at pinasa nya sa unang parameter anu ung ipapasa nya sa pangalawang parameter ng isShort()?

Paanu nya ikukumpara ung "hi" sa second parameter?

Isa pa sa magulo dito hnd nmn ako nagpasa ng argument. Tinwag ko lng xa as isShort na walang parenthesis, so paanu nalalaman ng compiler kung anu ung kukunin nya?
 
help po. need namen na mapag merge ng multiple pictures and save as a JPEG.

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Tests extends JFrame implements ActionListener {
private static final int verticalGap = 100;
private static final int horizontalGap = 30;
private static final int width = 800;
private static final int height = 800;
private JButton reg,regs;
private JLabel picture,pictures;
Icon pic,pics;


Tests() {
super();
//background
JLabel background = new JLabel(new ImageIcon("layouts/body bg.jpg"));
background.setLayout(new FlowLayout(FlowLayout.LEADING, horizontalGap, verticalGap));
add(background);

//Buttons
ImageIcon hair = new ImageIcon("button/hair.png");

reg = new JButton(hair);

background.add(reg);

regs = new JButton("button");
background.add(regs);

reg.addActionListener(this);
regs.addActionListener(this);

//Images
picture = new JLabel();
pictures = new JLabel();
pic = new ImageIcon("face/27.png");
pics = new ImageIcon("face/28.png");

background.add(picture);
background.add(pictures);
}

public void actionPerformed(ActionEvent event) {
if(event.getSource() == reg) {
picture.setIcon(pic);
}
else if(event.getSource() == regs) {
pictures.setIcon(pics);
}
}

public static void main(String args[]) {
Tests jb = new Tests();
Toolkit toolkit = Toolkit.getDefaultToolkit ();
Dimension dim = toolkit.getScreenSize();
jb.setSize(dim.width,dim.height);
jb.setDefaultCloseOperation(EXIT_ON_CLOSE);
jb.setVisible(true);
}
}

- - - Updated - - -

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Tests extends JFrame implements ActionListener {
private static final int verticalGap = 100;
private static final int horizontalGap = 30;
private static final int width = 800;
private static final int height = 800;
private JButton reg,regs;
private JLabel picture,pictures;
Icon pic,pics;


Tests() {
super();
//background
JLabel background = new JLabel(new ImageIcon("layouts/body bg.jpg"));
background.setLayout(new FlowLayout(FlowLayout.LEADING, horizontalGap, verticalGap));
add(background);

//Buttons
ImageIcon hair = new ImageIcon("button/hair.png");

reg = new JButton(hair);

background.add(reg);

regs = new JButton("button");
background.add(regs);

reg.addActionListener(this);
regs.addActionListener(this);

//Images
picture = new JLabel();
pictures = new JLabel();
pic = new ImageIcon("face/27.png");
pics = new ImageIcon("face/28.png");

background.add(picture);
background.add(pictures);
}

public void actionPerformed(ActionEvent event) {
if(event.getSource() == reg) {
picture.setIcon(pic);
}
else if(event.getSource() == regs) {
pictures.setIcon(pics);
}
}

public static void main(String args[]) {
Tests jb = new Tests();
Toolkit toolkit = Toolkit.getDefaultToolkit ();
Dimension dim = toolkit.getScreenSize();
jb.setSize(dim.width,dim.height);
jb.setDefaultCloseOperation(EXIT_ON_CLOSE);
jb.setVisible(true);
}
}
 
Ayos. Hindi nako mahihirapan sa pagcocode. Sana makatulong to as much as possible para sa katulad ko na bago sa c++. :) First year college here. :beat:
 
pa help nmn po
1. write a java application that declares variable to represent the length and width oa a room in feet. Compute and display the floor space of the room in square feet {formula: area = length * width). use room as its class name.

2. write a program that will prompts the user to enter a distance in kilometers and outputs the distance inputted by the user inmiles. use distance as its class name

note: 1 kilometer is equivalent to 0.62137 miles.


[email protected] p email nalang po tnx sa makakatulong sakin
 
@Nelzkie99

ang problema di ko maintidihan kung paanu kumukuha ng argument ung isShort()
yung stable_sort ang sisihin mo, hehe
ang <algorithm> function na toh ang bahala na sa pagbibigay ng arguments kay isShort

Kpag kinuha nya na argument ung unang string sa words at pinasa nya sa unang parameter anu ung ipapasa nya sa pangalawang parameter ng isShort()?
Paanu nya ikukumpara ung "hi" sa second parameter?
Unang-una, ang stable_sort na ang bahala dyan; ang kelangan mo lang ay magbigay ng dalawang iterator at optional na comparitor(yung binary predicate moh).
Code:
template<class BidirectionalIterator, class BinaryPredicate> void stable_sort(BidirectionalIterator _First, BidirectionalIterator _Last,BinaryPredicate  Comp);
Ang ginagawa ng stable_sort ay iniiterate nya ang binagay mong ranges(yung dalawang iterator). Sa bawat iteration, nagbabatoh sya ng argument sa binagay mong binary predicate. Halimbawa: sa first iteration, ibabatoh nya ang "hi" at "hello" sa isShort, sa second iteration eh yung "hello" at "hey" nman and so on..., Note: halimbawa ko lang toh, hindi toh ang mismong implementation ng stable_sort

Nung una, hindi ko din toh magets pero nung nagtagal nakuha ko din, naalala ko tuloy banong-bano ako dito dati, :lol:
 
Last edited:
Mga ka symb may alam kayong website na maraming guides for Java programming? 1st year IT student here
 
Create a class called Date that includes three pieces of information as instance variables—a month (type int), a day (type int) and a year (type int). Your class should have a constructor that initializes the three instance variables and assumes that the values provided are correct. Provide a set and a get method for each instance variable. Provide a method displayDate() that displays the month, day and year separated by forward slashes (/). Write a test application named DateTest that demonstrates class Date’s capabilities.

pa help assignment nmin hehe. 1st yr BSIT

test application nlng pla kulang ko hehe
 
Last edited:
I need help to create Jack n Poy flowchart for my Java Class..

Thank you in advance:)
 
pwede po bang patulong sa assignment ko ung dining philosophers po pangalan nung problem. c++ po gamit CLI po tska GUI
 
hello sir gandang hapon.. sa devc namin ngaun nasa Loop na kami .. medjo lito pa ako ng kunti .. san ba dapat maganda gamitin c do , do while , at for??

baka bigyan kami ng quiz bukas gamitin ung Loop.. patulong nman para maintindhan ko pa tong Loop ng mas mabuti .. salamat po..
 
Hi, I am still new to programming and specifically java and I want to understand this code. If you can atleast tell me or teach me how this code is being defined. It is better if you can put comments in every line. Please help me.


The problem to do is:
According to Wikipedia, n-gram is a contiguous subsequence of n items from a given sequence of text or speech. An n-gram of size 1 is referred to as a "unigram"; size 2 is a "bigram"(or, less commonly, a "digram"); size 3 is a "trigram".Larger sizes are sometimes referred to by the value of n, e.g.,"four-gram","five-gram",and so on.
A word can be broken down into sequences of elements based on the size of n as defined. For example, if we want to get the bigram of the word HELLO, then we will get the following: HE,EL,LL,and LO. If we try the trigram using the same word, we will get HEL,ELL, and LLO. Your task is simple. Given a particular word, you are to find teh number of sequences defined in the n-gram.

Input format
Each line in the input file contains the string S and the value of N in the n-gram.

Output format
For each line of input, you are to display the number of sequences that can be generated by the n-gram.

Input file:
HELLO 2
HELLO 3
PHILIPPINES 4



//Not my code
import java.io.*;

public class ngram{
public static void main(String args[]) throws IOException
{
BufferedReader inFile = new BufferedReader(new FileReader("gram.txt"));

String str = " ";

String text[ ];
text = new String[2];
String word;
int size, length;


while((str = inFile.readLine()) != null)
{
text = str.split(" ");
word = text[0];
size = Integer.parseInt(text[1]);
length = word.length();
int x[];
x = new int[length];
int y = 0;
int z = length;
for(y = 0; y < length; y++) {

x[y] = z;
z--;
}

System.out.println(x[size-1]);
}
}
}

Sample Output
4
3
8
 
Back
Top Bottom