Please fix all the errors in the code below

Assignment Help Basic Computer Science
Reference no: EM13930089

Question1: Please fix all the errors in the code below

public class Homework1 {

            public static void main(String[] args) {

                        int  i1 = 10;           // line1

                        double   d1 = 5.0;          // line2

                        float  f1 = 2.05;          // line3

                        char   c1 =  i1;          // line4

                        short   s1 = c1;          // line5

                        float  f2 = d1 / f1;          // line6

                        double d2 = f1 + i1 + c1;          // line7

                        float  f3 = d1 - i1;          // line8

                        byte b1 = 3;          // line9

                        byte b2 = 4;          // line10

                        byte b3 = 2 * b1 - b2;          // line11

            }

}

 

 

Question2: (25 points)            Calculate the value of d1 and d2:

            int i = 15;

            int j = 10;

            float f1 = 2;

            float d1 =  i / j;

            float d2 =  i / f1;

d1 =

d2 =

 

Question 3:

What is the value of a, b, i, j after the statements below are excuted.

int a = 10; 

int b = 5; 

int i =  ++a

int j = b--; 

a =

b =

i =

j=

 

Question 4:

What's the difference between continue and break?

 

 

 

 

Question 5:  

public class Example {

            public static void main(String[] args) {

                        int i = 1;

                        while (i <= 10) {

                                    i = i + 2;

                                    System.out.print(i + "  ");

                        }                     

            }

}

Output:

 

Question 6:  

public class Example {

            public static void main(String[] args) {

                        for (int k = 20; k >=10; k = k -3)  {

                        System.out.print(k + "  ");

                        }

            }

}

Output:

 

Question 7:

Please give an example to show value returning method and void method.

Reference no: EM13930089

Questions Cloud

Install microsoft access : After you install Microsoft Access, please use the Microsoft Website Support of Getting Started to learn the steps of creating a database for your assignment. You find the tutorials https://support.office.com/en-us/article/Access-2013-training-course..
Cellular firm that reported net income : Grammy phone is a cellular firm that reported a net income of $50 million in the most recent financial year. The firm had $1 billion in debt, on which it reported interest expenses of $100 million in the most recent financial year. Assuming that ther..
Does a bigger brain make you smarter : Does a bigger brain make you smarter? i. An Introduction (
What are the ethical issues : (a) Who are the stakeholders in this situation? (b) What are the ethical issues? (c) What would you do as the chief financial officer?
Please fix all the errors in the code below : Question1: Please fix all the errors in the code below public class Homework1 {             public static void main(String[] args) {
Create a personal budget spreadsheet for one year : You are to create a personal budget spreadsheet for one year that will list expenses and income for 12 months. The purpose of this assignment is to learn basic MS Excel features
What is the annual interest rate for this account : Use the formula for continuous compounding A = Pert, where A is the account balance after t years for the principal P and annual interest rate r (in decimal form). A deposit of $7000 is placed in a savings account for 2 years. The interest is compoun..
Increases economic efficiency : International trade increases economic efficiency and how trade barriers and tariffs inhibit efficiency
Interest is paid semiannually-the price of the bond : A bond is issued at par ($1,000.00) and has 10 years remaining to maturity. The bond bears interest at 7% and the yield to maturity (YTM) is 6%. Interest is paid semiannually. The price of the bond is:

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Prove that machine precision as bound for relative round off

Prove that machine precision (epsilon) calculated by mathlab's eps function can be utilized as a bound for relative round off.

  Make a class for a singly linked circular list

Make a class for a singly linked circular list that has no end and no beggining. The only access on the list is a single reference, current, that can point to any link on the list.

  About use the boost methodology

You are required to logically extend the functionality of the Maze Game introduced during lectures, via the modification of the code base as well as documentation and implementation of various user stories.

  What does the memory model of a microcontroller show

What does the memory model of a microcontroller show? Discuss the reasons for different types of memory such as RAM, EEPROM, and FLASH used in HCS12.

  Write a program that reads a java source

write a program that reads a java source file and produce index of all identifiers in the file. use the call in.useDelimeter("[^A-Za-zO-9-J]")

  Virtualization

Virtualization

  Where identifier is any valid identifier

Where identifier is any valid identifier and namespace-body is the set of classes, objects and functions that are included within the namespace.

  Analysis of competitive organization and possible threats

Analysis of competitive organization and possible threats and how organization is using E-Business Management facilities for daily activities? Limitations if any, adding more features for E-Business if required.

  Discuss some key characteristics of load lines

Explain the key quantities from the data sheet of your selected transistor. Based on your selected data sheet, what are the most important quantities to be considered for a circuit designer, and why. Discuss some key characteristics of "load lines,..

  Computer ethics the deep web or green computing

Choise a technology topic to research on the internet, such as cloud computing. Web 2.0, computer ethics, the deep web, or green computing. Using the techniques you learned in this lesson, search for web related to your topic.

  What is the propagation delay on a circuit using a leo

What is the propagation delay on a circuit using a LEO satellite orbiting 500 miles above the earth if the speed of the signal is 186,000 miles per second? If the satellite is 22,000 miles above the earth?

  A static data member annual interest rate

A static data member annualInterestRate that stores the annual interest rate for each of the savers.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd