1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
algol [13]
4 years ago
14

Write a JAVA program containing a method called hasEight(), which takes an int as input and returns true if the number contains

the digit 8 (e.g., 18, 808). Your program must implement the method and take input from the user. Please upload only your .java file for full credit. Any other file type and programs without the hasEight() method will not receive any credit.
Computers and Technology
1 answer:
skelet666 [1.2K]4 years ago
7 0

Here's my code for that, consider it under the WTFPL (http://www.wtfpl.net/). Here is a pastebin of the code, as to avoid text formatting. (Link: https://pastebin.com/S3BDGxqm Raw: https://pastebin.com/raw/S3BDGxqm)

package javaapplication6;

import java.util.Scanner;

public class JavaApplication6 {

   

   public static void main(String[] args) {

       

       Scanner myScanner = new Scanner(System.in);

       

       boolean a;

       int s;

       System.out.println("Enter an int");

       s = myScanner.nextInt();

       a = hasEight(s);

       System.out.println(a);

       

   }

   private static boolean hasEight(int s)

   {

       String str = String.valueOf(s);

       return str.contains("8");

   }

   

}

You might be interested in
Susan is in charge of the inventory reports for her company.She will need to find specific inventory items as well as project in
Nezavi [6.7K]

Answer:

lookup function

Explanation:

We can use the lookup function to find some values or reference in a range, we can use this syntax: LOOKUP( value, lookup_range, [result_range] ), where value is what we are going to look for, lookup_range is the single row or column is the range, and result_range is an optional part, in this range we're going to get the value.

8 0
4 years ago
• The length of time between water level measurements/ control adjustments is DT. • If the water level drops to the bottom of th
VikaD [51]

Answer:

Water level control systems are used to control the level and flow of water circulation systems for a variety of processes. The device that performs the controlling action is a valve which is attached to a controller whose main objective is to maintain a desired set point level as well as accept a new one desired by the control engineer.Fuzzy logic is widely used in the control of many processes, including that of the control of the water level in a tank.

DESIGN APPROACH

The system consists of a tank, a valve, a fuzzy logic controller, the inputs (level, rate) and the outputs (scopes).The tank system is modelled using SIMULINK and consists of two pipes; one flowing in and the other flowing out denoted by inflow and outflow respectively. The fuzzy controller controls the valve that changes the diameter of the inflow pipe but the outflow rate depends on the diameter of the outflow pipe (which is constant) and the pressure ( which depends on the level ) of the water. Thus, by keeping the water level at the desired set-point, we ensure that the tank works properly.

Water Level Control in a Tank PID(s) PID Controller Mux WATER TANK VALVE Mux2 S-Function SwitchSubsystem Mux tank 2 Sum1

The watertank design model, shown in the figure below, models a feedback loop for regulating the water level in a water tank. The Controller block contains the first-order compensator to be tuned.

The simulink model of the control system is

mdl = 'watertank_comp_design';

open_system(mdl);

Voltage for H 10-C- (++ Input Output Desired Water Level Controller Scope Water-Tank Systemm

The Water Tank subsystem models the water-tank dynamics. Water enters the tank from the top at a rate proportional to the voltage, V, applied to the pump. The water leaves through an opening in the tank base at a rate that is proportional to the square root of the water height, H, in the tank. The presence of the square root in the water flow rate makes the plant nonlinear.

Simulation

Simulate controller response with periodic changes in the setpoint of the water level. When you run the model, the Rule Viewer updates dynamically to show which rule the fuzzy controller is using to set the flow rate.

sim('sltankrule',100);

bdclose('sltankrule');

4 0
4 years ago
Business customers pay $0.006 per gallon for the first 8000 gallons. If the usage is more than 8000 gallons, the rate will be $0
trasher [3.6K]

Answer:

#include <bits/stdc++.h>

using namespace std;

int main()

{

   // variables

   char cust_t;

   int no_gallon;

   double cost=0;

   cout<<"Enter the type of customer(B for business or R for residential):";

   // read the type of customer

   cin>>cust_t;

   // if type is business

   if(cust_t=='b'||cust_t=='B')

   {

       cout<<"please enter the number of gallons:";

       // read the number of gallons

       cin>>no_gallon;

       // if number of gallons are less or equal to 8000

       if(no_gallon<=8000)

       {

           // calculate cost

           cost=no_gallon*0.006;

           cout<<"total cost is: $"<<cost<<endl;

       }

       else

       {

           // if number of gallons is greater than 8000

           // calculate cost

           cost=(8000*0.006)+((no_gallon-8000)*0.008);

           cout<<"total cost is: $"<<cost<<endl;

           

       }

       

   }

   

   // if customer type is residential

   else if(cust_t=='r'||cust_t=='R')

        {

           

       cout<<"please enter the number of gallons:";

       // read the number of gallons

       cin>>no_gallon;

       // if number of gallons are less or equal to 8000

       if(no_gallon<=8000)

       {

           // calculate cost

           cost=no_gallon*0.007;

           cout<<"total cost is: $"<<cost<<endl;

       }

       else

       {// if number of gallons is greater than 8000

       // calculate cost

           cost=(8000*0.005)+((no_gallon-8000)*0.007);

           cout<<"total cost is: $"<<cost<<endl;      

       }        

   }

return 0;

}

Explanation:

Ask user to enter the type of customer and assign it to variable "cust_t". If the customer type is business then read the number of gallons from user and assign it to variable "no_gallon". Then calculate cost of gallons, if  gallons are less or equal to 800 then multiply it with 0.006.And if gallons are greater than 8000, cost for  first 8000 will be multiply by 0.006 and  for rest gallons multiply with 0.008.Similarly if customer type is residential then for first 8000 gallons cost will be multiply by 0.005 and for rest it will  multiply by 0.007. Then print the cost.

Output:

Enter the type of customer(B for business or R for residential):b                                                                                            

please enter the number of gallons:9000                                                                                                                      

total cost is: $56  

4 0
4 years ago
Who was responsible for unleashing the melissa computer virus
CaHeK987 [17]

Answer:

David L. Smith

Explanation:

Around March 26, 1999, the Melissa virus was released by David L. Smith

‘Melissa.A’ used social engineering techniques, since it came with the message “Here is the document you asked me for…  do not show it to anyone”. In just a few days, she starred in one of the most important cases of massive infection in history, causing damage of more than 80 million dollars to American companies. Companies like Microsoft, Intel and Lucent Technologies had to block their Internet connections due to its action.

How it Works

When opening a document infected with the ‘Melissa.A’, the virus creates an e-mail with the following features:

Subject: Important Message From “sender name”

Text: Here is that document you asked for … do not show anyone else

Attachments: a file with a DOC.

The recipients of this message were the first 50 addresses ‘Melissa.A’ found in the address book in Outlook. This was the first macro virus that used this technique, until this moment there hadn’t been a virus that affected users by sending a Word document within an email.

What Happened

The creator of ‘Melissa.A’, David L. Smith, pleaded guilty but said he did not expect such high economic damage. This malware was created in memory of a topless dancer in Florida with whom he had fallen in love with.

Smith was sentenced to 10 years in prison.

6 0
3 years ago
If an occupation is projected to decline by 7% over the next 10 years, how would you rate the job outlook?
Helen [10]
Steady sounds like the best answer but that’s tough
5 0
3 years ago
Other questions:
  • In Linux, when logged in as a normal user with root privileges, which command must precede the apt-get command in the command li
    13·1 answer
  • _____ is a function performed by control programs that manages computer resources, such as storage and memory.
    11·1 answer
  • Reinstalling a software package to fix a problem with an inoperative program is an example of which troubleshooting strategy?
    9·1 answer
  • The Internet began when a large company wanted to sell products online. True False
    15·2 answers
  • True and False: High-speed Internet service is free form of information technology that these businesses can utilize.
    13·1 answer
  • Which of these is an aggregator?
    5·2 answers
  • #include
    11·1 answer
  • E-mail messages, instant messages (IMs), or text messages sent and/or received within an organization a. are not included on a r
    9·1 answer
  • 10. Question<br> What are the drawbacks of purchasing something online? Check all that apply.
    5·1 answer
  • if you are trying to reduce the cost of college, which of the following strategies is likely to save you the most money?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!