hiya i am looking if someone can help me create this in java there is an attachments alongside this

Attachments Varialbes.jpg 96.52 KB

the code for this is extremely simple and has only basic functionality. what do you have so far? what are you having problems with?

the code for this is extremely simple and has only basic functionality. what do you have so far? what are you having problems with?

i dont have anything so far but a couple of line like creating the bytes and inetgers

byte input;
byte Type;
int output;
// creating 2 bytes and 1 integer

public void input (byte input,byte Type, int output){


if (Type = 1) output = (input*input) / 2;
//if type = 2 output = input*input*input;
//if type = 3 output = input*2;
//else output = input*1000;

you'll need to put them all in a certain scope.
step 1: create your class 'Control1'
according to your assignment, this has just 1 variable in it, an int called output.
step 2: add a method that takes two params, input and type. you don't pass output, since you already have that in your class
don't add the logic yet
step 3: add a second method, which does not take any parameters.

write the code so far, and post it here.

you'll need to put them all in a certain scope.
step 1: create your class 'Control1'
according to your assignment, this has just 1 variable in it, an int called output.
step 2: add a method that takes two params, input and type. you don't pass output, since you already have that in your class
don't add the logic yet
step 3: add a second method, which does not take any parameters.

write the code so far, and post it here.

so far i have this

public class Control1 {

byte input;
byte Type;
int output;
// creating 2 bytes and 1 integer

public void input (byte input,byte Type, int output){


if Type = 1 output = (input*input) / 2;
if type = 2 output = input*input*input;
if type = 3 output = input*2;
else output = input*1000;
}


}

you don't need to have your bytes in your class scope, only in your first method. so:

public class Control1{

int output; // this is your ONLY class variable!!

public void input(byte input, byte type){
// you already have output, you don't need to pass it as a parameter
}

public void secondMethod(){
// second method => no parameters
}
}

now check if you can see how to implement the right functionality in there.

you don't need to have your bytes in your class scope, only in your first method. so:

public class Control1{

int output; // this is your ONLY class variable!!

public void input(byte input, byte type){
// you already have output, you don't need to pass it as a parameter
}

public void secondMethod(){
// second method => no parameters
}
}

now check if you can see how to implement the right functionality in there.

i tried nothing working i amd new to java dont understand everything

as I said, this is very basic material.
just paste the code you've tried and isn't working in the thread. I can't find any errors based on the information that 'it's not working'

as I said, this is very basic material.
just paste the code you've tried and isn't working in the thread. I can't find any errors based on the information that 'it's not working'

where do i put this part of the coding

if type = 1 output = (input*input) / 2;
if type = 2 output = input*input*input;
if type = 3 output = input*2;
else output = input*1000;

where do i put this part of the coding

if type = 1 output = (input*input) / 2;
if type = 2 output = input*input*input;
if type = 3 output = input*2;
else output = input*1000;

it says some sort of brackets are missing

first of all, that is no java coding, it looks more like pseudocode, which will not compile.
there is only one method that has access to the input and type variables, because it has been passed that as parameters. you'll have to correct your code and paste it in there.

first of all, that is no java coding, it looks more like pseudocode, which will not compile.
there is only one method that has access to the input and type variables, because it has been passed that as parameters. you'll have to correct your code and paste it in there.

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/


package controlflow1;


/**
*
*
*/

public class Control1  {

int output; // Only class variable!!

public void input(byte input, byte type){  //

if type = 1 output = (input*input) / 2;

if type = 2 output = input*input*input;

if type = 3 output = input*2;

else output = input*1000;
}

public void secondMethod(){}// second method => no parameters


}

please can you fill the blanks please i really dont understand this at all or what you ar saying please can you fill the blanks for medf

Edited 3 Years Ago by diafol: fixed formatting

as I said, that is pseudocode, not correct java code.
check this link for some more explanation about the if-else statement in java.

why dont you write me an if statement with the pesudo code i provided you with please

I'm not just doing it, because the purpose of this forum is to help you improve your coding skills, not to help you cheat on some homework.

when comparing the value of a primitive datatype (byte, for instance) you'll need to use '=='. if you're just using '=' it means you are assigning it a value.
also, you must think about how and where to put which brackets.

the link I provided you with contains all the information you need to correct your code.

This article has been dead for over six months. Start a new discussion instead.