수다닷컴

  • 해외여행
    • 괌
    • 태국
    • 유럽
    • 일본
    • 필리핀
    • 미국
    • 중국
    • 기타여행
    • 싱가폴
  • 건강
    • 다이어트
    • 당뇨
    • 헬스
    • 건강음식
    • 건강기타
  • 컴퓨터
    • 프로그램 개발일반
    • C언어
    • 비주얼베이직
  • 결혼생활
    • 출산/육아
    • 결혼준비
    • 엄마이야기방
  • 일상생활
    • 면접
    • 취업
    • 진로선택
  • 교육
    • 교육일반
    • 아이교육
    • 토익
    • 해외연수
    • 영어
  • 취미생활
    • 음악
    • 자전거
    • 수영
    • 바이크
    • 축구
  • 기타
    • 강아지
    • 제주도여행
    • 국내여행
    • 기타일상
    • 애플
    • 휴대폰관련
  • 프로그램 개발일반
  • C언어
  • 비주얼베이직

java관련 질문인데요, 여기서 뭐가 잘못된거죠?

하나

2023.04.01


다항식의 계산과 관련되서 프로그램 소스를 만드는 중입니다.


숫자간의 곱셈과 덧셈인데, 제가 생각한것처럼 되지않네요.;;;
잘못된 부분을 어떻게 고쳐야하는지 좀 봐주세요(아랫부분에 소스코드있습니다.)public class main {
public static void main(string[] args) {

scanner s = new scanner(system.in);
quadratic q = new quadratic();

system.out.println(type any number to change the coefficients);
system.out.println(input the coefficient of second power of x);
double coef1 = s.nextdouble();
system.out.println(input the coefficient of first power of x);
double coef2 = s.nextdouble();
system.out.println(input the coefficient of zero power of x);
double coef3 = s.nextdouble();

q.change(coef1, coef2, coef3);
q.getcoefficient();

system.out.println(input a number to evaluate the quadratic equation.);
double coef4 = s.nextdouble();
q.evaluate(coef4);

system.out.println(input three coefficients of another quadratic equation in order from second power to zero power.);
double coef5 = s.nextdouble();
double coef6 = s.nextdouble();
double coef7 = s.nextdouble();
q.sum(coef5, coef6, coef7);
q.getcoefficient();

system.out.println(input a multiplier.);
double coef8 = s.nextdouble();
q.scale(coef8);
q.getcoefficient();
}}여기까진 메인이구요===============================================================================================public class quadratic { private double a;
private double b;
private double c; public quadratic() // constructor - set all coefficient equal zero.
{
a = 0;
b = 0;
c = 0;
}
public double change( double input1, double input2, double input3)
{
a = input1;
b = input2;
c = input3; return 0; // does not return anything. it just change the value of a, b, and c.
}
public void getcoefficient() // ??accessor method 이렇게 해도되나? 이렇게 아니고 public int getcoefficient()로 하면
{ // 리턴값이 하나밖에 없지않나? 어떻게 3개의 상수를 return하나??
system.out.println(the current value of coefficient is + a + , + b + , and + c + .);
system.out.println(so, it is + a + x^2 + + b + x + + c + .);
}
public double evaluate(double input4)
{
double result = a * input4 * input4 + b * input4 + c;
return result;
}
public double sum(double input_1, double input_2, double input_3)
{
a = a + input_1;
b = b + input_2;
c = c + input_3; return 0; //does not return anything. it just change the value of a, b, and c.
}
public double scale(double input5)
{
a = a * input5;
b = b * input5;
c = c * input5; return 0; //does not return anything. it just change the value of a, b, and c.
}
}위에 public double evaluate 부분에서요 제가 input으로 1을 집어 넣었더니다음과같이 결과가 뜨네요.input a number to evaluate the quadratic equation.
1
input three coefficients of another quadratic equation in order from second power to zero power.
보시다시피, 1을 넣었을때를 계산하지않고 그냥 넘어가버리는데요, 이게 왜 이런가요??

신청하기





COMMENT

댓글을 입력해주세요. 비속어와 욕설은 삼가해주세요.

  • 큰솔

    return은 말그대로 값을 돌려준다는 겁니다 함수를 호툴한 부분에 값을 돌려주는 거지 화면에 출력하는 명령은 아닙니다.

  • 유희

    q.Evaluate 하면 return값이 출력되는거 아닌가욤? +_+?

  • 지희

    계산은 하는데 출력하는부분이 없네요...

번호 제 목 글쓴이 날짜
2699518 javaScript중복체크 하는법좀.. 알려주세요 (3) 비 2025-06-26
2699495 이런 탭메뉴를 뭐라고 해야 하는지 모르겠네요 (1) 들빛 2025-06-26
2699380 메뉴가 계단식으로 나타나요.. ㅠ.ㅠ (5) 스릉흔다 2025-06-25
2699354 영문 웹폰트 관련 질문입니다!!! (1) 치킨마루 2025-06-25
2699329 윈도우 미디어 플레이어 URL 질문!!! (1) 제철 2025-06-25
2699296 동영상 배경 질문드려요!!!!!!!!!!!!!! 핫파랑 2025-06-24
2699214 position:fixed 에 대한 질문입니다.. (7) 사이 2025-06-24
2699183 제이쿼리 이미지 슬라이드 위치값 수정 초엘 2025-06-23
2699153 테마[ADORABLE]에서 페이지생성시 하위페이지는 2개밖에 안되나요? 흰여울 2025-06-23
2699129 네이버 블로그 또는 사이트의 글을 불러오기 갤원 2025-06-23
2699070 탭메뉴처럼 셀렉트 박스를 이용해서 내용을 출력할 수 있는 방법이 있을까요. (3) 큰꽃늘 2025-06-22
2699016 인터넷이 안되는 환경에서 validator설치방법 (3) 은송이 2025-06-22
2698988 대체 C++ 6.0 exe 아이콘은 어떻게 넣는건가요? 외국녀 2025-06-22
2698960 음성파일을 embed로 작업했는데..웹 표준코딩으로 변경하려면 어떻게 해야하나요? (1) 잎새 2025-06-21
2698932 메뉴목록 풍선창 만들기 html (2) 하늘이 2025-06-21
2698901 http://www.zeitgeistbot.com/ 이 사이트처럼 움직이는 효과를 무엇이라고 하나요? 누림 2025-06-21
2698876 table width값 크로스브라우징에 대한 문의 (2) 볼수록매력 2025-06-21
2698849 c언어 질문. (3) 아름나 2025-06-20
2698823 setInterval 이벤트 제거 하려면... 가온길 2025-06-20
2698796 이 오류를 이해를 못하겠어요 Addicted 2025-06-20
<<  이전  1 2 3 4 5 6 7 8 9 10  다음  >>

수다닷컴 | 여러분과 함께하는 수다토크 커뮤니티 수다닷컴에 오신것을 환영합니다.
사업자등록번호 : 117-07-92748 상호 : 진달래여행사 대표자 : 명현재 서울시 강서구 방화동 890번지 푸르지오 107동 306호
copyright 2011 게시글 삭제 및 기타 문의 : clairacademy@naver.com