Question

FIX THE FOLLOWING JAVA CODE

public class Errors public static main(String[] args) { float sum int a = 27.5, b = 72.99; suma(a, b); System.out.println(Su

0 0
Add a comment Improve this question Transcribed image text
Answer #1

`Hey,

Note: If you have any queries related the answer please do comment. I would be very happy to resolve all your queries.

public class Errors{

public static void main(String []args){
float sum=0;
float a=27.5f;
double b=72.99;
sum=suma(a,b);
System.out.printf("Suma = %7.3f",sum);
}
public static float suma(float a,double b)
{
float sum;
sum=a+(float)b;
return sum;
}
}//end class

M Inbox - gurkaranpreet.singh.me@ X C Computer Science question | Che X </> Online Java Compiler - Online Ja X C My Q&A | Che

Kindly revert for any queries

Thanks.

Add a comment
Know the answer?
Add Answer to:
FIX THE FOLLOWING JAVA CODE public class Errors public static main(String[] args) { float sum int...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Analyze the following code: public class Test { private int t; public static void main(String[] args)...

    Analyze the following code: public class Test { private int t; public static void main(String[] args) { int x; System.out.println(t); } } t is non-static and it cannot be referenced in a static context in the main method. The program compiles and runs fine. The variable t is not initialized and therefore causes errors. The variable x is not initialized and therefore causes errors.

  • Analyze the following code: public class Test { private int t; public static void main(String[] args)...

    Analyze the following code: public class Test { private int t; public static void main(String[] args) { int x; System.out.println(t); } } The variable t is private and therefore cannot be accessed in the main method. The program compiles and runs fine. t is non-static and it cannot be referenced in a static context in the main method. The variablet is not initialized and therefore causes errors. The variable x is not initialized and therefore causes errors.

  • What are the errors in this ? public class Mystery { public static void main(String[] args)...

    What are the errors in this ? public class Mystery { public static void main(String[] args) { double initialSavings = 10000; double interestRate = 0.05; double currSavings = 0; int i;    System.out.println("\nAnnual savings 5 years: "); currSavings = initialSavings; for (i = 0, i < 5, ++i); currSavings = (currSavings * interestRate); System.out.println("$" + currSavings); }    }

  • Given the following Java code: public static void main (String[] args) { int num; System.out.println("Enter a...

    Given the following Java code: public static void main (String[] args) { int num; System.out.println("Enter a number"); num = scan.nextInt(); <-first input statement while (num != 0) { System.out.println ("The number is: " + num); System.out.println("Enter a number"); num = scan.nextInt(); } //End While } //End Module The first input statement shown above is called the:

  • This is for a java program public class Calculation {    public static void main(String[] args)...

    This is for a java program public class Calculation {    public static void main(String[] args) { int num; // the number to calculate the sum of squares double x; // the variable of height double v; // the variable of velocity double t; // the variable of time System.out.println("**************************"); System.out.println(" Task 1: Sum of Squares"); System.out.println("**************************"); //Step 1: Create a Scanner object    //Task 1. Write your code here //Print the prompt and ask the user to enter an...

  • Fix 15 errors in the code below public class CallingMethodsInSameClass {         string fName = Joe;...

    Fix 15 errors in the code below public class CallingMethodsInSameClass {         string fName = Joe;         string lName = Hasley;         string fullName;         public static void main(String[] args) {                  printOne()                  concatThem()         }         public static void printOne() {                  System.out.println(Hello World)                 public static void concatThem() {         fullName = fName + “ “ + lName;         if(fullName.equals(fName + lName){      system.out.println(“It’s a match! fullName is: “ + fullname”)         }         else        ...

  • how to change this code to string instead of int    public static void main(String[] args)...

    how to change this code to string instead of int    public static void main(String[] args) {        int[] sample = { 212, 580, 6, 7, 28, 84, 112, 434};        Dictionary bst = new Dictionary();        for (int x : sample) {            bst.insert(x);        }        System.out.println(bst.find(65));        System.out.println(bst.smallest());        System.out.println(bst.largest()); //       bst.delete(84);        System.out.println(bst.numOfLeafNodes());        System.out.println(bst.height());        bst.traverseInOrder();    } }

  • Identify a logical error in the following code and fix it. public class test1 {    ...

    Identify a logical error in the following code and fix it. public class test1 {     public static void main(String[] args){         int total;         float avg;         int a, b, c;         a=10;         b=5;         c=2;         total=a+b+c;         avg=total/3;         System.out.println("Average: "+avg);     } } Answer: Write the output of the program below. import java.util.Scanner; public class test2 { public static void main(String[] arg){ int psid; String name; Scanner input=new Scanner(System.in); System.out.println("Enter your PSID"); psid=input.nextInt(); System.out.println("Enter your...

  • Review the following code: public class Looping {    public static void main(String[] args) {      ...

    Review the following code: public class Looping {    public static void main(String[] args) {       for (int i = 1; i <= 5; i++) {          for (int j = 1; j <= 5; j++) {             System.out.println(i + " x " + j + " = " + (i * j));          }       }    } } What is the output from the code above? Replace this text with your solution What happens if you change the...

  • What is the Java output? Part One: class Driver { public static void main(String[] args) {...

    What is the Java output? Part One: class Driver { public static void main(String[] args) { int a = 5; int b = 3; if (a < b || a * 2 < b) System.out.print(a - b); System.out.print(b + a); } } Part Two: class Driver { public static void main(String[] args) { int a = 5; int b = 8; if (a < b) if (a * 2 < b) System.out.print("foo"); else System.out.print("bar"); else System.out.print("buz"); } }

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT