
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Java
What's the output of the following program...
a.) Compilation Error
b.) 97~B~C~D~E~102~G~
c.) 65~b~C~d~E~70~G~
d.) a~66~C~68~E~f~G~
![What will be the output of the following program?
class ForTest
{
public static void main(String[] arg
s)
{
for (char i = 'A'; i <= 'G'; i++
{
if (i % 5 == 0)
{
System.out.print((char)
(1 - 'A' + 'a'));
}
else if (i % 2 == 0)
{
System.out.print((int) i
);
}
else
{
System.out.print(i);
}
System.out.print('~');
}](https://content.bartleby.com/qna-images/question/c332541b-17c6-4d35-8ed8-689d66016651/cd2097a3-fe52-4651-bdd7-3c2ee1578aac/f9vxj3a_thumbnail.png)
Transcribed Image Text:What will be the output of the following program?
class ForTest
{
public static void main(String[] arg
s)
{
for (char i = 'A'; i <= 'G'; i++
{
if (i % 5 == 0)
{
System.out.print((char)
(1 - 'A' + 'a'));
}
else if (i % 2 == 0)
{
System.out.print((int) i
);
}
else
{
System.out.print(i);
}
System.out.print('~');
}
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 3 steps with 1 images

Knowledge Booster
Similar questions
- Software engineering case study homework (PLAGIARISM WILL BE DETECTED !!!) Please provide an upload link for the file This case study is about a simplified Payphone coin system.1. The minimum price of a communication is 10 ryals.2. After the introduction of the currency, the user has 2 minutes to dial his number (this time iscounted by a time counter).3. The line can be free or busy.4. The Payphone consumes money as soon as the called person picks up and at each time unitgenerated by the counter.5. You can add pieces of money at any time.6. At the time of the hang-up, the balance of the currency introduced (the rest of the money) isreturned. Required work:From this statement, you are asked to:1. Establish the use case diagram of this statement.2. Construct a sequence diagram that describes the nominal scenario of Payphoning use case inthis statement.arrow_forwardCSCI 2436:01L Data Structures Lab Lab 1 - Chapter 4 The Efficiency of Algorithms In this lab, you will practice how to measure the running time f a section of code in Java. One approach is to use System.nano Time() where the current time is stored as a long integer equals to the number of nanoseconds. By subtracting the starting time in nanoseconds from the ending time in nanoseconds, you get the run time-in nanoseconds of a section of code. public static void main(String[] args) { int n1 = 10, n2 = 100, n3 = 1000, n4 = 10000; long n1Time, n2Time, n3Time, n4Time; n1Time AlgorithmA (nl); For example, suppose that AlgorithmA is the name of a method you wish to time. The following statements will compute the number of nanoseconds that AlgorithmA requires to execute: } public static long AlgorithmA (int n) { long startTime, endTime, elapsedTime; startTime = System.nanoTime (); int sum = 0; for (int i = 1; i 0 1 2. By midnight, Tuesday, Jan 24th, submit your Java source file and a…arrow_forwardanswer b and c You are obligated to answer 3 subpartsarrow_forward
- Java Programming: 6.) Acme Parts runs a small factory and employs workers who are paid one of three hourly rates depending on their shift: first shift, $17 per hour; second shift, $18.50 per hour; third shift, $22 per hour. Each factory worker might work any number of hours per week; and hours greater than 40 are paid at one and one-half times the usual rate. In addition, second- and third shift workers can elect to participate in the retirement plan, for which 3 percent of the worker’s gross pay is deducted from the paychecks. Write a program that prompts the user for hours worked and the shift number; if the shift number is 2 or 3, prompt the user to enter the worker’s choice to participate in the retirement plan. Display (1) the hours, (2) the shift, (3) the hourly pay rate, (4) the regular pay, (5) overtime pay, (6) the total of regular and overtime pay, (7) the retirement deduction, if any, and (8) the net pay. Save the file as AcmePay.java. Input/output would be appreciated!arrow_forwardPlease help me in c++ languagearrow_forwardPYTHON Q9: Assignment statements, such as x = 3, define variables in programs. To execute one in an environment diagram, record the variable name and the value: Evaluate the expression on the right side of the = sign Write the variable name and the expression's value in the current frame. Use these rules to draw a simple diagram for the assignment statements below. x = 10 % 4 y = x x **= 2arrow_forward
- Part 7 for all 1.Prepare two payrolls programs for the following cases: Casel: it is considered that there is one kind(category) of employee. The payment is the sum of the base salary and the overtime. (mainal.java) 8 Case2: it is considered that there are two kind (categories) of employees. For the first category (designers, consultants) the payment is the sum of the base salary and the overtime. (as in case 1). For the second category (sales representatives sales manager )the payment is the sum of base salary and the commission times the sales of amounts. (maina2.java) Please prepare the following: a. The class diagrams for both cases. b. The programs for both cases. For the second case consider commission=0.02. The use of interface is necessary for the second case. 2. A function (calculatePrice() computes the discount of a product. The initial case contains discounts: 10%,20%,30% on a price. Prepare the most appropriate Javascript part of program that can compute the new price for…arrow_forwardRewrite the following code segment using a multiple selection statement in Javaarrow_forwardMathematical functions introduced in chapter 4 can be used in the mathematical calculations and simulations of the engineering and scientific problems. In these cases, we formulate the mathematical problem and then use the computer for calculations and simulations. Can a computer code solve the math problem and come up with mathematical formulas, i.e. can a computer program do what a mathematician does?arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY

Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON

Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education

Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY