Questions
Core Java Do exercise 9a, 9b, 9c, & 9d with indented code and comments. 9a. public...

Core Java

Do exercise 9a, 9b, 9c, & 9d with indented code and comments.

9a.

public class Demo {

              public static void main(String[] args) {

                            //create Employee object with int 101, String Sam,salary 1000 data

                            //display this object data by passing to show method

                            //add 100 bonus in salary

                            //display this object data by passing to show method

              }

              public static void show(){

                            //do required changes in show method

              }

}

9b.

public class Demo {

              public static void main(String[] args) {

                            //create Employee object with int 101, String sam, salary 1000 data

                            //display this object data by passing to show method

                            //add 100 bonus in salary

                            //display this object data by passing to show method

              }

              public void show(){

                            //do required changes in show method

              }

}

9c. In below example ,try to call show method in different ways which explains different ways to call static methods

public class Demo {

              public static void main(String[] args) {

                            //call show method in different ways

              }

              public static void show(){

                            System.out.println("show method");

              }

}

9d. In below example, try to print total variable in different ways which explains different ways to call static variable

public class Demo {

              private static int total = 10;

              public static void main(String[] args) {

                            //print total in different ways

              }

}

In: Computer Science

Invoice Class - Create a class called Invoice that a hardware store might use to represent...

Invoice Class - Create a class called Invoice that a hardware store might use to represent an invoice for an item sold at the store. An Invoice should include four pieces of information as instance variables—a part number (type String), a part description (type String), a quantity of the item being purchased (type int) and a price per item (double).

  • Your class should have a constructor that initializes the four instance variables. If the quantity passed to the constructor is not positive, it should be set to 0 by the constructor. If the price per item passed to the constructor is not positive, it should be set to 0.0 by the constructor.

  • Provide a set and a get method for each instance variable. If the quantity passed to the setQuantity method is not positive, it should be set to 0 by the method. If the price per item passed to the setPricePerItem method is not positive, it should be set to 0.0 by the method.

  • Provide a method named getInvoiceAmount that calculates the invoice amount (i.e., multiplies the quantity by the price per item), then returns the amount as a double value.

Write a test app named InvoiceTest that demonstrates class Invoice’s capabilities. Create two Invoice objects, print their state, and invoice amounts.

Please this is what I have and I know it should work , but I keep getting these errors.

PA3.2.java:1: error: class, interface, or enum expected

Invoice class

^

PA3.2.java:1: error: <identifier> expected

Invoice class

   ^

PA3.2.java:69: error: <identifier> expected

InvoiceTest class wth main method

   ^

PA3.2.java:69: error: '{' expected

InvoiceTest class wth main method

   ^

PA3.2.java:90: error: reached end of file while parsing

}

^

5 errors

error: compilation failed

When I try and fix them, that's when I get this error. error: can't find main(String[]) method in class: Invoice

Please someone help me!!!!!

Invoice class


public class Invoice
{
private String partNumber;
private String description ;
private int quantity;
private double pricePerUnit;

//constructor that initializes the four instance variables
public Invoice(String partNumber, String description, int quantity, double pricePerUnit) {
this.partNumber = partNumber;
this.description = description;
if(quantity>0)
this.quantity = quantity;
else
this.quantity = 0;
if(pricePerUnit>0)
this.pricePerUnit = pricePerUnit;
else
this.pricePerUnit = 0;
}
//getters and setters methods
public String getPartNumber() {
return partNumber;
}

public void setPartNumber(String partNumber) {
this.partNumber = partNumber;
}

public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}

public int getQuantity() {
return quantity;
}

public void setQuantity(int quantity) {
if(quantity>0)
this.quantity = quantity;
else
this.quantity = 0;
}

public double getPricePerUnit() {
return pricePerUnit;
}

public void setPricePerUnit(double pricePerUnit) {
if(pricePerUnit>0)
this.pricePerUnit = pricePerUnit;
else
this.pricePerUnit = 0;
}
//method that computes the total price and return it
public double getInvoiceAmount()
{
return pricePerUnit*quantity;
}
}

InvoiceTest class wth main method

public class InvoiceTest {
public static void main(String[] args) {
Invoice obj1 =new Invoice("P101","Iphone 7" , 100, 20.5);
Invoice obj2 =new Invoice("P102","Iphone 10" , 10,799 );
  
System.out.println("Product Number : "+obj1.getPartNumber());
System.out.println("Product Desc. : "+obj1.getDescription());
System.out.println("Quantity : "+obj1.getQuantity());
System.out.println("Price per unit : $"+obj1.getPricePerUnit());
System.out.println("Invoice Amount : $"+obj1.getInvoiceAmount());
  
  
System.out.println("\n\nProduct Number : "+obj2.getPartNumber());
System.out.println("Product Desc. : "+obj2.getDescription());
System.out.println("Quantity : "+obj2.getQuantity());
System.out.println("Price per unit : $"+obj2.getPricePerUnit());
System.out.println("Invoice Amount : $"+obj2.getInvoiceAmount());
}
  
}

In: Computer Science

the language is matlab 1) Write a code that will print a list consisting of “triangle,”...

the language is matlab

1) Write a code that will print a list consisting of “triangle,” “circle,” and “square.” It prompts the user to choose one, and then prompts the user for the appropriate quantities (e.g., the radius of the circle) and then prints its area. If the user enters an invalid choice, the script simply prints an error message. For calculating the area, create separate functions for each choice. Name them as calcTriangle, calcCircle, calcSquare respectively, which are only for area calculation. All the input and output should be in the main script. The main script part should include a nested ifelseif statement. Here are two examples of running it (units are assumed to be inches). For test cases, you need to test all three options. >> Problem 4 >> Problem 4 Menu Menu 1. Triangle | Enter 1 for Triangle 1.Triangle | Enter1 for Triangle 2. Circle | Enter 2 for Circle 2. Circle | Enter 2 for Circle 3. Square | Enter 3 for Square 3. Square | Enter 3 for Square Please choose one: 1 Please choose one:2 Enter the height of the Triangle: 5 Enter the radius of the Circle: 5 Enter the base length of the Triangle: 4 The area of the Circle is 78.54 The area of the triangle is 10.00

In: Computer Science

Imagine you are developing a software package for an online shopping site that requires users to...

Imagine you are developing a software package for an online shopping site that requires users to enter their own passwords. Your software requires that users' passwords meet the following criteria: The password should be at least six characters long. The password should contain at least one uppercase and at least one lowercase letter. The password should have at least one digit. Write a class that verifies that a password meets the stated criteria. Demonstrate the class in a program that allows the user to enter a password and then displays a message indicating whether it is valid or not.

I wrote the following code and I am receiving errors, can someone debug this?

import java.util.Scanner;

class Main {

public static void main (String []args)

{

String password; // to hold input entered by the user

boolean hasupperletters = false;

boolean haslowerletters = false;

boolean hasdigits = false;

boolean wronginput = false;

//create a scanner object and ask for input.

Scanner keyboard = new Scanner(System.in);

System.out.print("Create your password");

password = keyboard.nextLine();

int passlength= password.length();

//loop to go through all characters in the password String

for (int i = 0; i < passLength; i++){

char c = input.charAt(i);

//check for at least one uppercase character

if(Character.isUpperCase(c))

hasupperletters = true;

//check for at least one lowercase character

else if (Character.isLowerCase(c))

haslowerletters=true;

//check for at least one digit

else if(Character.isDigit(c))

hasdigits = true;

}

//check for correctly formatted password

if(hasupperletters && hasdigits && haslowerletters && !wronginput && (passlength>=6))

{

System.out.println("Password is correctly formatted");

}

else

{

System.out.println("Password is not correctly formatted");

}

}

}

In: Computer Science

1a. Convert 67 (base 10) to 8-bit binary using signed magnitude. Show your work. 1b. Convert...

1a. Convert 67 (base 10) to 8-bit binary using signed magnitude. Show your work.

1b. Convert 69 (base 10) to 8-bit binary using one’s complement. Show your work

1c. Convert 70 (base 10) to 8-bit binary using two’s complement. Show your work.

1d. Convert - 67 (base 10) to 8-bit binary using signed magnitude.

1e. Convert - 67 (base 10) to 8-bit binary using ones compliment. Show your work.

1f. Convert - 67 (base 10) to 8-bit binary using 2s compliment. Show your work.

In: Computer Science

unsigned u =10; int i = -42; cout << i+i <<endl; cout << u+i<<endl;//if int take...

unsigned u =10;
int i = -42;
cout << i+i <<endl;
cout << u+i<<endl;//if int take 32 bit, output 4294967264

I know when unsigned and singed operate together, they need to be converted, but why is the answer 4294967264? What does it have to do with int .…… 32 bit

In: Computer Science

(PHP and MySQL) How do you determine what size (in terms of subtype or length) a...

(PHP and MySQL)

How do you determine what size (in terms of subtype or length) a column should be?

What are some of the other properties that can be assigned to columns?

What is a primary key?

if you`re using the command-line myaql client to connect to MySQL,What username and password combination is required?

In: Computer Science

Write a RECURSIVE method that receives a string as a parameter. The method will return true...

Write a RECURSIVE method that receives a string as a parameter. The method will return true if the string received as a parameter is a palindrome and false if it is not.

The method must not have any loops!

In JAVA

In: Computer Science

1) Design and implement a method to double all elements of an array. Important: You don’t...

1) Design and implement a method to double all elements of an array.

Important: You don’t need to test test method in main(). You don’t need to initialize the array.

pubilc static void doubleElements(int [] arr)

{

}

2) Start with the code below and complete the getInt method. The method should prompt the user to enter an integer. Scan the input the user types. If the input is not an int, throw an IOException; otherwise, return the int. In the main program, invoke the getInt method, use try-catch block to catch the IOException.

import java.util.*;

import java.io.*;

public class ReadInteger

{

pubilc static void main()

{

// your code goes here

}

public static int getInt() throws IOException

{

// your code goes here

}

}

3) Create a class called Car (Car.java).

It should have the following private data members:

• String make

• String model

• int year

Provide the following methods:

• default constructor (set make and model to an empty string, and set year to 0)

• non-default constructor Car(String make, String model, int year)

• getters and setters for the three data members

• method print() prints the Car object’s information, formatted as follows:

Make: Toyota

Model: 4Runner

Year: 2010

public class Car

{

}

4) Complete the following unit test for the class Car described above. Make sure to test each public constructor and each public method, print the expected and actual results.

// Start of the unit test of class Car

public class CarTester

{

public static void main()

{

// Your source codes are placed here

return;

}

}

In: Computer Science

Using, if possible your own experience, essay is needed on the benefits and dangers of the...

Using, if possible your own experience, essay is needed on the benefits and dangers of the grapevine (communication) in a large group of students in a university. Discuss also the ethical considerations. (please discuss in detail up to 500 words)

In: Computer Science

Write a program that uses a dictionary to assign “codes” to each letter of the alphabet....

Write a program that uses a dictionary to assign “codes” to each letter of the alphabet. For example:

     codes = {'A':'%', 'a':'9', 'B':'@', 'b':'#', etc....}

Using this example, the letter “A” would be assigned the symbol %, the letter “a” would be assigned the number 9, the letter “B” would be assigned the symbol “@” and so forth.

The program should open a specified text file, read its contents, and then use the dictionary to write an encrypted version of the file’s contents to a second file. Each character in the second file should contain the code for the corresponding character in the first file. Additionally, the order of the characters will be reversed. In other words, the encrypted version of the first character in the original file will be last in the new file, the encrypted version of the second character will be second to last in the new file, and so on. The encrypted version of the last character in the original file will be the first character in the new file.

Write a second program that opens an encrypted file and displays its decrypted contents on the screen.

Place your Python code and a screen shot of the output from both of your programs for #2 here (2 codes and 2 screen shots).

In: Computer Science

1a. What is the largest negative number that you could represent with 7 bits using signed...

1a. What is the largest negative number that you could represent with 7 bits using signed magnitude? Show your work.

1b. What is the largest positive number that you could represent with 7 bits using 2’s complement? Show your work.

1c. Add the following two binary numbers 10110111 + 1011 = :Show your work.

1d. Solve the following decimal notation equation using 8-bit binary numbers and 2’s complement notation: 69 - 7 = :Show your work

In: Computer Science

Java Palindrome Use StringBuilder concept to create a palindrome checker.   Method should be called pCheck. Must...

Java Palindrome

Use StringBuilder concept to create a palindrome checker.  

Method should be called pCheck.

Must use var-arg concept.  

Class name for this program is Palindrome.  

Must pass this test::

public class PalindromeTest {

public static void main(String[] args) {

Palindrome palindrome = new Palindrome();

boolean answer = palindrome.pCheck("racecar", "Bell", "elle", "bunny");

System.out.println(“These are palindromes: " + answer);

}

}

In: Computer Science

***Please answer the question using the JAVA programming language. Write a program that calculates mileage reimbursement...

***Please answer the question using the JAVA programming language.

Write a program that calculates mileage reimbursement for a salesperson at a rate of $0.35 per mile. Your program should interact (ask the user to enter the data) with the user in this manner:

MILEAGE REIMBURSEMENT CALCULATOR

Enter beginning odometer reading > 13505.2

Enter ending odometer reading > 13810.6

You traveled 305.4 miles. At $0.35 per mile, your reimbursement is $106.89.

** Extra credit 6 points: Format the answer (2 points), use JavaDoc (2 points), use constant for the rate per mile (2 points).

In: Computer Science

In pseudocode, consider the DOWHILE repetition control structure. Control passes to the next statement after the...

In pseudocode, consider the DOWHILE repetition control structure. Control passes to the next statement after the delimeter ENDDO (and no further processing takes place within the loop) when which of the following occurs? a condition p is found to not evaluate to true or false a condition

p is found to be true

a condition p is found to null

None of the other answers are correct

a condition p is found to be false

In: Computer Science