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

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

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