EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
9th Edition
ISBN: 9781337671385
Author: FARRELL
Publisher: CENGAGE LEARNING - CONSIGNMENT
bartleby

Concept explainers

bartleby

Videos

Expert Solution & Answer
100%
Book Icon
Chapter 2, Problem 1CP

Explanation of Solution

Program code:

CarlysEventPrice.java

//import the required header files

import java.util.Scanner;

//define a class named CarlysEventPrice

public class CarlysEventPrice

{

//define main() method

public static void main(String args[])

{

//create the object of Scanner class

Scanner scanner = new Scanner(System.in);

//prompt the user to enter the number of guests

System.out.println("Enter number of guests: ");

//scan for the values

int n = scanner.nextInt();

//print the values

System.out.println("Number of guests: "+n);

System.out.println("Price per guests: "+35);

System.out.println("Total price: "+(n*35));

//if the value of n is grater than or equal to 0

if(n>=0)

//print true

System.out.println("true");

//if the value of n is less than 0

else

//print false

System.out.println("false");

}

}

Explanation:

The above snippet of code is used to calculate the price per guest...

Blurred answer
Students have asked these similar questions
Visual Studio 2017 Using C#.  How to write this in C#. The problem is : A software company sells a package that retails for $99. Quantity discounts are given. For quantities of 1-9, 0% discount is given. 10-19, 20% discount. 20-49, 30% discount. 50-99, 40% discount. 100 or more 50% discount. Create an application that lets the user enter the number of packages purchased. The program should then display the amount of the discount (if any) and the total amount of the purchase after the discount. The form should have a text box for quantity, discount percent, amount you saved, final price and a calculate button that will calculate and output to discount percent text box, discount amount text box, and final price after discount text box. Assume the only values entered will be between 1 - 150. Use the decimal data type for all your variables except the quantity,which is an integer.Add TryParse method to catch illegal data, only integers are ok. pop up a message box if that happens noting…
Scientists measure an object’s mass in kilograms and its weight in Newtons. If you know the amount of mass of an object, you can calculate its weight, in Newtons, with the following formula:                                    Weight = Mass × 9.8Create an application that lets the user enter an object’s mass and then calculates its weight. If the object weighs more than 1000 Newtons, display a message indicating that it is too heavy. If the object weighs less than 10 Newtons, display a message indicating that it is too light.
This code needs to be written in C#: If the user guesses the number in 3rd try you will assign:Points = (10 – 3)^2/100 = 7 ^ 2 = 49 points.When the user presses the ‘Start Game’ button, the game will start. User will enter a number in the largetextbox and press Submit. If number is correct display the Messagebox, else continue with game. Also tellthe user if the number entered was higher or lower than actual number.The problem flow will be as follows:1. Player enters name and number of chances2. Player presses Start game3. Computer generates a secret random number4. Player enters choice5. Program checks if number matches guesses number. If number matches jump to step #106. Program updates message whether the guessed number is more or less than actual7. Program reduces available chances by 1 and display messages on changes8. If chances become 0 stop game and tell use Game has ended, and she will have to press ‘Start Game’again. Same message should be spoken by the program using text to…
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
Introduction to Classes and Objects - Part 1 (Data Structures & Algorithms #3); Author: CS Dojo;https://www.youtube.com/watch?v=8yjkWGRlUmY;License: Standard YouTube License, CC-BY