Question

Write a complete method calculateCost that accepts two parameters: a char representing package code for photo orders and a ch

Java Language

0 0
Add a comment Improve this question Transcribed image text
Answer #1

PLEASE NOTE : FEEL FREE TO ASK ANY DOUBTS by COMMENTING

:::::::::::::::::::::::::::::::::::::::::::: CODE :::::::::::::::::::::::::::::::::::::::::::

public class Main
{
public static double calculateCost(char base,char addon){
double amount = 0;
switch(base){
case 'A':
amount = 12;
break;
case 'B':
amount = 24;
break;
case 'C':
amount = 40;
break;
case 'D':
amount = 70;
break;
}
switch(addon){
case 'J':
amount = amount+5;
break;
case 'K':
amount = amount+5;
break;
case 'M':
amount = amount+10;
break;
}
return amount;
}
   public static void main(String[] args) {
       System.out.println(calculateCost('A','J'));
       System.out.println(calculateCost('B','Z'));
   }
}

:::::::::::::::::::::::::::::::::::::::::::: OUTPUT ::::::::::::::::::::::::::::::::::::::::

17.0 24.0 ... Program finished with exit code o Press ENTER to exit console.

:::::::::::::::::::::::::::::::::::::: CODE in EDITOR ::::::::::::::::::::::::::::::::::

Main.java 1 public class Main 2 - { 3 public static double calculateCost(char base, char addon) { double amount = 0; switch(b

_________________________________________________________________

Dear Friend, Feel Free to Ask Any Doubts by Commenting. ASAP i'll respond when i'm available.

I'm on a critical situation. Please Do Not Forget To Give A Thumbs UP +1. It will Helps me A Lot.

Thank YOU :-)

Add a comment
Know the answer?
Add Answer to:
Java Language Write a complete method calculateCost that accepts two parameters: a char representing package code...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In Java code Write a complete method name convertFile that accepts a File object representing an...

    In Java code Write a complete method name convertFile that accepts a File object representing an input text file and a PrintWriter objects as arguments. The method should read the contents of the input file and change all characters to uppercase and store the results in the output file.

  • Submit Chapter6.java with a public static method named justifyText that accepts two parameters; a Scanner representing...

    Submit Chapter6.java with a public static method named justifyText that accepts two parameters; a Scanner representing a file as the first parameter, and an int width specifying the output text width. Your method writes the text file contents to the console in full justification form (I'm sure you've seen this in Microsoft Word full.docx ).  For example, if a Scanner is reading an input file containing the following text: Four score and seven years ago our fathers brought forth on this...

  • Write code in Java programming language. The ShoppingCart class will be composed with an array of...

    Write code in Java programming language. The ShoppingCart class will be composed with an array of Item objects. You do not need to implement the Item class for this question, only use it. Item has a getPrice() method that returns a float and a one-argument constructor that takes a float that specifies the price. The ShoppingCart class should have: Constructors: A no-argument and a single argument that takes an array of Items. Fields: • Items: an array of Item objects...

  • I need java code for the following problem. Lab 7: Methods 1. Write a Java program called Numbers that calls the following methods and displays the returned value: Write a method called cubelt that a...

    I need java code for the following problem. Lab 7: Methods 1. Write a Java program called Numbers that calls the following methods and displays the returned value: Write a method called cubelt that accepts one integer parameter and returns the value raised to the third power as an integer. o Write a method called randominRange that accepts two integer parameters representing a range. The method returns a random integer in the specified range inclusive. 2. o Write a method...

  • Using Java: 1. Recursive Multiplication Write a recursive function that accepts two arguments into the parameters...

    Using Java: 1. Recursive Multiplication Write a recursive function that accepts two arguments into the parameters x and y. The function should return the value of x times y. Remember, multiplication can be performed as repeated addition as follows: 5×6=6+6+6+6+6 2. Recursive findings Write a recursive boolean method named reFinding. The method should search an array for a specified value, and return true if the value is found in the array, or false if the value is not found in...

  • 3. Write Java methods to accomplish each of the following Write a method named simpleAry which...

    3. Write Java methods to accomplish each of the following Write a method named simpleAry which accepts and return nothing. It creates an array that can hold ten integers. Fill up each slot of the array with the number 113. Then, display the contents of the array on the screen. You must use a loop to put the values in the array and also to display them. Write a method named sury which accepts an array of type double with...

  • In Java programming language Please write code for the 6 methods below: Assume that Student class...

    In Java programming language Please write code for the 6 methods below: Assume that Student class has name, age, gpa, and major, constructor to initialize all data, method toString() to return string reresentation of student objects, getter methods to get age, major, and gpa, setter method to set age to given input, and method isHonors that returns boolean value true for honors students and false otherwise. 1) Write a method that accepts an array of student objects, and n, the...

  • Write a method named printGrid that accepts two integer parameters rows and cols. The output is...

    Write a method named printGrid that accepts two integer parameters rows and cols. The output is a comma-separated grid of numbers where the first parameter (rows) represents the number of rows of the grid and the second parameter (cols) represents the number of columns. The numbers count up from 1 to (rows x cols). The output are displayed in column-major order, meaning that the numbers shown increase sequentially down each column and wrap to the top of the next column...

  • Write Java code to implement a FSM machine that recognizes the language for the alphabet {a,b,c} ...

    Write Java code to implement a FSM machine that recognizes the language for the alphabet {a,b,c} consisting of all strings that contain two consecutive c's and end with b.                   Your FSM program should include the following three static methods (Java) or functions (C):                                           a.    int nextState(int state, char symbol)                                  A state-transition function that returns the next state based on the                                  current state and an input symbol. This function should also return                                  -1 when an invalid input character is detected.                                  State...

  • Write a Java class called BankAccount (Parts of the code is given below), which has two...

    Write a Java class called BankAccount (Parts of the code is given below), which has two fields name (String) and balance (double), two constructors and five methods getName(), getBalance(), deposit (double amount), withdraw(double amount) and toString(). The first constructor should initialize name to null and balance to 0. The second constructor initializes name and balance to the parameters passed. deposit method deposits the amount to the account causing the current balance to increase, withdraw method withdraws the amount causing the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT