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

  Linear programming model to be formulated and used

What are the assumptions for a linear programming model to be formulated and used?

  Provide your reasoning using ethical codes of conduct

Beside each situation below, place a check by the term(s) that best reflects your opinion of the behavior of the individual. Provide your reasoning for each of your answers using both the ethical codes of conduct and the information on computer cr..

  A table of data from a text file

In this lab you will write a program to read in a table of data from a text file where each line represents a record, and manipulate it. Each line of the input file will consist of sequence of quoted strings (using double quotation marks) separated b..

  What is called a whitespace character

Given an int variable modelYear write a statement that assigns true to norecall if the value of modelYear does NOT fall within the two recall ranges and assigns false otherwise. Do not use an if statement in this exercise!

  Components-protocols to support management of certificates

A Public Key Infrastructure (PKI) is a collection of components and protocols to support the management of certificates that bind a user name to a public key.

  Explain elements of enterprise information security policy

Write and explain briefly the three kinds of information security policy as described by NIST SP 800-14. Write and explain briefly four elements that must be present in Enterprise Information Security Policy.

  Briefly discuss the various organizational approaches

1) As a member of an IT staff, how can you use social media to support e-commerce? You can search business websites to find good practices of using social media in e-commerce.

  Determine whether or not the two conditions are equivalent

Determine whether or not the two conditions are equivalent - that is, whether they will be true or false for exactly the same values of the variables appearing in them.

  Access the administrative tools

Access the Administrative Tools

  Describe the formula for elasticity of demand

O. Describe the formula for elasticity of demand for labor as well as the significance of elastic versus inelastic findings. How does this compare with the elasticity of labor supply? P. What is the labor-leisure trade-off? On figure 8.5, describe t..

  Excels multiple worksheet abilities

Question 1. Excel's multiple worksheet abilities can do all of the following EXCEPT: (a) create Pivot Charts. (b) group worksheets together to enter data. (c) display worksheets side by side. (d) IN create links among the worksheets.

  First describe the mission of each organization

First describe the mission of each organization, as found on their web site.  Discuss how each organization has been targeted in the recent past for cyberattack(s), as reported in news or journal articles.  Describe the suspected threat actors.  Disc..

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