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!

-= Having Difficulties in C++ and Java? Be a Part of This Thread =-

Tanong lang about Java: Paano ko maaccess yung private variable (let's say: private String nameStud) na nasa class na studentInfo sa isa pang class na regOffice? gusto ko kasing idisplay ung laman nung nameStud sa class na regOffice.TIA sa makakasagot :)
 
Tanong lang about Java: Paano ko maaccess yung private variable (let's say: private String nameStud) na nasa class na studentInfo sa isa pang class na regOffice? gusto ko kasing idisplay ung laman nung nameStud sa class na regOffice.TIA sa makakasagot :)

Getters pafs.

Kung eclipse gamit mo:

Source-generate setters and getters para madali.
 
Last edited:
Sir meron po ba kayong tutorial for beginners? kasi iba course ko gusto ko talga matuto ng C++ and java :clap:
 
good day... pahelp naman po sa c++ programming, bigla nalang po kasi nag pagawa si prof eh, eto po problem,

program that will let the user input 1 to 20 numbers(kahit anung nos po) and it display all the even numbers in ascending order

#include<iostream>
using namespace std;
int main()
{
int a,b,input;




for(a=1;a<=20;a++)
{
cout<<"Enter Digit:";
cin>>b;
cin.ignore();
}

if(b%2==0)
{
cout<<b;
}

cin.get();
return 0;

}

:thanks:
 
Last edited:
Store mo muna sa array ang even numbers na nainput mo then sort and print.
 
@Mak016 Just make a public method that wil return the value of the private variable then just call that public method. ex: public String getNameStud(){return nameStud;}
 
sorry, madami na pala nagtatanong, di ko na kasi navisit itong thread simula nung magkasakit ako
 
good day... pahelp naman po sa c++ programming, bigla nalang po kasi nag pagawa si prof eh, eto po problem,

program that will let the user input 1 to 20 numbers(kahit anung nos po) and it display all the even numbers in ascending order

#include<iostream>
using namespace std;
int main()
{
int a,b,input;




for(a=1;a<=20;a++)
{
cout<<"Enter Digit:";
cin>>b;
cin.ignore();
}

if(b%2==0)
{
cout<<b;
}

cin.get();
return 0;

}

:thanks:

Code:
#include <iostream>
using namespace std;

void swap(int &a, int &b){
	int c = a;
	a = b;
	b = c;
}

void doSort(int x[], int N){	
  for (int i = 0; i < N-1; i++){
      for (int j = i+1; j < N; j++){
          if (x[i] > x[j])
             swap(x[i], x[j]);
      }
  }
}

int main(){

	int a, b, input, store[20];
	for(a=0;a<20;a++){
		cout<<"Enter Digit:";
		cin>>b;
		store[a] = b;
	}
	doSort(store,20);
	for (int a = 0; a < 20; a++)
		if(store[a]%2==0)
			cout << store[a] << " ";	

	return 0;
}
 
Tanong lang about Java: Paano ko maaccess yung private variable (let's say: private String nameStud) na nasa class na studentInfo sa isa pang class na regOffice? gusto ko kasing idisplay ung laman nung nameStud sa class na regOffice.TIA sa makakasagot :)

Bawal po ata siya, dapat "public" yung variable dun sa isang class

Code:
// studentInfo.java

class studentInfo{
	public String nameStud = "Hello World";
}

Code:
// regOffice.java

class regOffice{
	public static void main(String args[]){
		studentInfo a = new studentInfo();
		System.out.println(a.nameStud);
		
		System.exit(0);
	}
}

NOTE: Kung gusto mo talaga na private yung nasa studentInfo class mo, ganito dapat code nyan

Code:
// studentInfo.java

class studentInfo{
	private String nameStud = "Hello World";
	public String getData(){
		return nameStud;
	}
}

Code:
// regOffice.java

class regOffice{
	public static void main(String args[]){
		studentInfo a = new studentInfo();
		System.out.println(a.getData());
		
		System.exit(0);
	}
}
 
Last edited:
pa update naman ng mga link sa front page
 
sir.. pahelp po about sa c++.

Codes/Program about PRIME AND PRIME FACTORIZATION.

kelangan ko ng program na if PRIME NUMBER ang gi-input ko,
mag-ooutput sya ng "PRIME",

and if COMPOSITE NUMBER naman ang gi-input ko,
e-ooutput nya ung PRIME FACTORS...


output example:

enter a number: 3
<< prime

enter a number: 8
<< 2 2 2 or (2x2x2) or (2.2.2)


Thanks...
 
mga sir panu po ito ?

attachment.php


pa Edit naman po itong code ko thanks :thumbsup:

Code:
[FONT="Courier New"]#include <conio.h>
#include <stdio.h>
int main()
{
    int val=10;
    int num=0, lst[val], odd[val], lstctr=0, oddctr=0,sum=0;
    for(int x=0; x<val; x++)
    {
            scanf("%d",&num);
            
            if(num%2==1)
                
            {
                odd[oddctr] = num;
                sum+=odd[oddctr];
                oddctr++;
            }
            if(x<val)
            {
                     lst[lstctr] = num;
                     lstctr++;
            }
            
    }
    
    printf("\n\nList\tODD");
    
    for( int i = 0; i < val; i++ )
    {
         
        if(i < lstctr)
         {
             printf("%i", lst[i]);
         }
         else
         {
             printf("");
         }
         
         if(i < oddctr)
         {
             printf("\n%i\t", odd[i]);
         }
         else
         {
             printf("\n \t");
         }
         
         
    }
    printf("Sum of Odd # is : %d",sum);
    getch();
}[/FONT]
 

Attachments

  • Capture.PNG
    Capture.PNG
    23.7 KB · Views: 91
sir.. pahelp po about sa c++.

Codes/Program about PRIME AND PRIME FACTORIZATION.

kelangan ko ng program na if PRIME NUMBER ang gi-input ko,
mag-ooutput sya ng "PRIME",

and if COMPOSITE NUMBER naman ang gi-input ko,
e-ooutput nya ung PRIME FACTORS...


output example:

enter a number: 3
<< prime

enter a number: 8
<< 2 2 2 or (2x2x2) or (2.2.2)


Thanks...

www.rel.phatcode.net/junk.php?id=132
primefactorsscreen.png


Java yan but it could be easily converted to c++.

@crismatel: What's the prob? Mukhang okay naman output mo.
 
Last edited:
sir.. pahelp po about sa c++.

Codes/Program about PRIME AND PRIME FACTORIZATION.

kelangan ko ng program na if PRIME NUMBER ang gi-input ko,
mag-ooutput sya ng "PRIME",

and if COMPOSITE NUMBER naman ang gi-input ko,
e-ooutput nya ung PRIME FACTORS...


output example:

enter a number: 3
<< prime

enter a number: 8
<< 2 2 2 or (2x2x2) or (2.2.2)


Thanks...

edit mo nalang ng unti :thumbsup:

Code:
#include <iostream>
using namespace std;

int main(){
   long long int num;
   string x = " x ";

   while (cout << "enter a number: ", cin >> num){		
     if ( num <= 1 )
       cout << num << " is unexpected input";
     else 
     cout << "<< ";
     
     for (int i = 2; i <= num; i++){
        while(num % i == 0){
           num = num / i;
           cout << i;             
           if(i<= num)            
               cout << x;
         }	      
      }
    cout << endl << endl;
    }
}
 
Last edited:
mga sir panu po ito ?

http://www.symbianize.com/attachment.php?attachmentid=763180&stc=1&d=1373095060

pa Edit naman po itong code ko thanks :thumbsup:

Code:
[FONT="Courier New"]#include <conio.h>
#include <stdio.h>
int main()
{
    int val=10;
    int num=0, lst[val], odd[val], lstctr=0, oddctr=0,sum=0;
    for(int x=0; x<val; x++)
    {
            scanf("%d",&num);
            
            if(num%2==1)
                
            {
                odd[oddctr] = num;
                sum+=odd[oddctr];
                oddctr++;
            }
            if(x<val)
            {
                     lst[lstctr] = num;
                     lstctr++;
            }
            
    }
    
    printf("\n\nList\tODD");
    
    for( int i = 0; i < val; i++ )
    {
         
        if(i < lstctr)
         {
             printf("%i", lst[i]);
         }
         else
         {
             printf("");
         }
         
         if(i < oddctr)
         {
             printf("\n%i\t", odd[i]);
         }
         else
         {
             printf("\n \t");
         }
         
         
    }
    printf("Sum of Odd # is : %d",sum);
    getch();
}[/FONT]

Code:
#include <conio.h>
#include <stdio.h>
int main()
{
    int val=10;
    int num=0, lst[val], odd[val], lstctr=0, oddctr=0,sum=0;
    for(int x=0; x<val; x++)
    {
            scanf("%d",&num);
			if(x<val)    
            {
				lst[lstctr] = num;
                lstctr++;
               
            }
             if(num%2==1)
            {
                odd[oddctr] = num;
                sum+=odd[oddctr];
                oddctr++;     
            }         
    }
    
    printf("\n\nList\tODD1");
    
    for( int i = 0; i < val; i++ )
    {
         if(i < lstctr)
         {
             printf("\n%i\t", lst[i]);
         }
         else
         {
             printf("\n \t");
         }
         if(i < oddctr)
         {
		 printf("%i", odd[i]);
         }
         else
         {
		 printf("");
            
         }

         
    }
    printf("\nSum of Odd # is : %d",sum);
    getch();
}
 
Last edited:
nice thread ts ah
makakatulong ito sakin lalo na java lesson namin ngayung 1st year
 
enjoy lang po kayo dito mga kapwa ko programmer :D
 
pa help naman po
http://*** BANNED LINK - DO NOT POST ***/aBQ6ACzT

need ko po output na Ascending Order :help:
 
Back
Top Bottom