How do you figure out how to declare a variable

Assignment Help JAVA Programming
Reference no: EM13940243

How do you figure out how to declare a variable? How do you know what type of variable to use? What is the best way to name a variable and why? What are the differences between an integer variable and a floating point variable? When and why do data type conversions occur? What is the modulus operator?

Write a short java statement for each question item

1) Declare a variable for each of the data types, pay attention to the naming convention and syntax

a. a int variable representing the number of students, the value of this variable is 45.

b. a double variable representing a student' s GPA.

c. a float variable representing the amount you need to pay for gas at a gas station.

d. a char variable that has the value of C.

e. a String variable containing the name of your pet/hometown/your favorite dish.

2) Write down the result for the following statement.

a. inta=15; float b = 15.0; ?c = a + b;?Question: the data type of c should be ___30___

b. inta=5;?double b = 15.0;?c = a + b;?Question: the value of c is ___20___, the data type of c is ___double____

c. int numOfPeople = 10;?int numOfApple = 4;?c = numOfPeople / numOfApple;?Question: the value of c is __2.5_____, the data type of c should be _______

d. int numOfPeople = 10;?int numOfApple = 4;?c = numOfPeople % numOfApple;?Question: the value of c is _______, the data type of c should be _______

e. int numOfPeople =10;?int numOfApple = 4;?double applePerPerson = 0.0;?applePerPerson = numOfPeople / numOfApple; Question: the value of applePerPerson is ______.

f. int num1 = 5; int num2 = 4; ?int result = num1 % numb2;?Question: the value of result is __________.

g. Let assume you have 1003 cents, using / and % to write a block of java statement to calculate the number of dollars, quarters, and cents you have.
Section Three

Write a block of pseudo code that captures the following federal tax bracket, please note that the following chart is an approximation of the tax bracket, but is not the actual tax bracket:

For people who file single status, Taxable income
0 - $8,500 $8500-$34,500 $34,500 - $83,600 $83,600 - $174,400 $174,400 - $379,150
$379,150 above
tax bracket 10%?15%?25%
28% 33%
35%

Reference no: EM13940243

Questions Cloud

Create a testrectangle class that tests both constructors : An overloaded constructor that takes integer width and height arguments, uses a separate method to check whether the width and height fall within the range between 0 and 30, and throws an exception if out of range.
Static and flexible budgets, variances, information quality : 10.22 - Static and flexible budgets, variances, information quality The photocopying department in a community college has budgeted monthly costs at $40,000 per month plus $7 per student. Normally 800 students are enrolled. During January there we..
Impact of the challenge on the system and society : Discuss the following with regards to an analysis of racial profiling in police stops and an analysis of wrongful convictions:- Impact of the Challenge on the System and Society and Historical Response to the Challenge and Strategies
What tax planning activities might pam consider : Since the major portion of Pam's income is based on commission, her earnings vary from one month to the next. This situation makes it difficult for her to establish a realistic budget. What tax planning activities might Pam consider
How do you figure out how to declare a variable : How do you figure out how to declare a variable? How do you know what type of variable to use? What is the best way to name a variable and why? What are the differences between an integer variable and a floating point variable? When and why do dat..
What is the value of etc according to mm with corporate tax : What is the value of ETC according to MM with corporate taxes?  What is ETC's value (rounded to the nearest 1000) according to MM (including personal taxes)?
How many trim kits must be sold for polaris to break even : If Polaris sells 20,000 door handles and 40,000 trim kits, what is the operating income? How many door handles and how many trim kits must be sold for Polaris to break even?
Should a property owner be allowed to use a bobby trap : Contrary to common law, today, in most states, a person cannot use deadly force in the defense of their property. Do you agree with this challenge? Should a property owner be allowed to use a bobby trap as long as notice, by use of sign for exampl..
Why does the program end abnormally : Using the Person and PersonRunner classes below, execute the main method in PersonRunner. Why does the program end abnormally?

Reviews

Write a Review

JAVA Programming Questions & Answers

  Write a program to register students for a college

Students have names, addresses and courses. Implement the interface class RegisterStudent. RegisterStudent has one method, public boolean register, which returns the boolean value of true or false if the student is successfully registered for the ..

  Write a java application that allows the user to read

Write a java application that allows the user to read, validate, store, display, sort and search the internet account number (integer number), usage (integer number) and cost (double number) for N customers. N should be declared as a constant and it ..

  Implement a class icecreamcone

Implement a class IceCreamCone with methods getSurfaceArea() and getVolumn(). In the constructor, supply the height and radius of the cone. Be careful when looking up the formula for the surface area

  Creates an array with x randomly generted integer elements

Write a program DuplicateTester.java that prompts user for a posi- tive integer x and creates an array with x randomly generted integer ele- ments in range 0 to 9. Use a method with signature public static int[] removeDuplicates(int[] array); to remo..

  Strong authentication can also risk availability

Strong authentication can also risk availability. A simple example is that forgetting your password denies you access to that which required a password. Sometimes the stakes are high, for example, if a network administrator is the only one who knows ..

  Method that reflects overloading

Example of a method that reflects overloading, and one that reflects polymorphism

  Complier error and run time error

Q1. What do you understand by complier error and run time error? Explain by example.

  Write a public static method writetokenstolines

Write a public static method called writeTokensToLines that will read an input file one token at a time using Scanner, and write the tokens to a file using a PrintWriter, one token per line, with the tokens numbered starting at 1.

  What value is assigned to the variable phrase

Create a class State with five properties to hold the information about a single state and a method that calculates the density (people per square mile) of the state.

  Java program that implements an algorithm known as a bubble

writing a simple Java program that implements an algorithm known as a Bubble Sort. A Bubble Sort is a simple sorting algorithm that takes an unsorted array of elements and sorts them into ascending order.

  Advance programming hi i want two copies of the assignment

hi ltbrgti want two copies of the assignment me and my friend are doing same assignment. ltbrgtwe need both the

  Survey conductor application

Survey Conductor Application: You have been asked by your manager to create a user-friendly application that will present a survey to your customers

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