Description
Unformatted Attachment Preview
Assignment 2
Write an application (including algorithm) that uses the predefined functions,
“exp” (exponential), “log10” (common logarithm), “fdim” (positive difference),
and “div” (integer division). The declaration of these functions are contained
in either “cmath” or “cstdlib” header files. Therefore, the header files must
be included in the application.
The application requires a loop that will run until the user makes a selection
to “Quit”. The application uses a menu (similar to Chapter 3 slide 108) that
displays a list of choices.
1)
2)
3)
4)
5)
Process
Process
Process
Process
Quit
Exponential Function
Common Logarithm Function
Positive Difference Function
Integer Division Function
Select a choice:
A switch statement is used to determine the choice. Each choice prompts for the
information, calls the predefined function and displays the result.
Upload to the Canvas “Assignment 2 Submission” area.
// Name:
// Email:
// Purpose: Create an application, “BooleanDecision” that displays // the results of a Boolean expression, including a
// declaration of an integer constant to represent the
// numeric value.
// Algorithm:
// Prompts the user for myNumber integer value
// Stores value in myNumber
// If the myNumber is less than 10 displays
// Number is less than 10
// Else if myNumber is greater than 10 displays
// Number is greater than 10
// Else displays
// Number is equal to 10
Purchase answer to see full attachment
Purchase answer to see full attachment
Explanation & Answer:
code
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.
Explanation & Answer
Please view explanation and answer below.Here is the program named as test.cpp.
Please view explanation and answer below.Here is the pseudocode in a .txt file. Let me know if you need anything else. Thanks!
//Name:
//Email:
//Purpose: Create an application that allows user to navigate menu o...
Completion Status:
100%
Review
Review
Anonymous
Very useful material for studying!
Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4
24/7 Homework Help
Stuck on a homework question? Our verified tutors can answer all questions, from basic math to advanced rocket science!
Most Popular Content
ECON 120B University of California Confidence Interval Stata Assignment 2
Hi, I need help with a Stata assignment, please follow all the instructions i attached and make sure it runs
ECON 120B University of California Confidence Interval Stata Assignment 2
Hi, I need help with a Stata assignment, please follow all the instructions i attached and make sure it runs
ITS 3105 SUS C Programming Ethics of Artificial Intelligence Paper & Reflection
read the description of the Eliza program at the bottom of this question. Is it ethical to make people think they are talk ...
ITS 3105 SUS C Programming Ethics of Artificial Intelligence Paper & Reflection
read the description of the Eliza program at the bottom of this question. Is it ethical to make people think they are talking to another person when they are not? Does it make a difference if they find the program to be helpful? Would you mind if a Help facility for some software you were using was a machine instead of a person? Have you ever been embarrassed when you thought you were talking to a person but later found out you were not? (For example, have you ever started to respond on the phone only to realize you were listening to an answering machine?)
import javax.swing.*;
public class Eliza
{
public static void main(String[] args)
{
String user;
String msg = "";
String msg1 = "Tell me more about your ";
String msg2 = "You seem to have strong feelings about that";
String msg3 = "Please go on";
String msg4 = "Tell me more";
String msg5 = "Continue";
int random;
int length;
int x, y;
int stopWord;
final String END = "Goodbye";
boolean foundMy = false, foundLove = false, foundHate = false;
user = JOptionPane.showInputDialog(null,
"Hello. I am Eliza, your tharapist. Tell me what" +
"\nis troubling you. Any time you want to quit," +
"\njust type \"Goodbye\"");
while(!user.equalsIgnoreCase(END))
{
user = user.toLowerCase();
length = user.length();
foundMy = false;
for(x = 0; x < length - 3; ++x) // If "my" is at end of sentence, no need to go further
{
if(user.charAt(x) == 'm')
{
if(user.charAt(x + 1) == 'y')
if(user.charAt(x + 2) == ' ')
if(x >= 1)
{
if(user.charAt(x - 1) == ' ')
foundMy = true;
}
else
foundMy = true;
}
if(foundMy)
{
stopWord = length;
for(y = x + 3; y < length; ++y)
{
if(user.charAt(y) == ' ' || user.charAt(y) == '.' || user.charAt(y) == ',')
stopWord = y;
}
msg = msg1 + user.substring(x + 3, stopWord);
x = length; // do not look for possible second "my"
}
}
if(!foundMy)
{
foundLove = false;
for(x = 0; x < length - 5; ++x)
{
if(user.charAt(x) == 'l')
{
if(user.charAt(x + 1) == 'o')
if(user.charAt(x + 2) == 'v')
if(user.charAt(x + 3) == 'e')
if(user.charAt(x + 4) == ' ')
if(x >= 1)
{
if(user.charAt(x - 1) == ' ')
foundLove = true;
}
else
foundLove = true;
}
if(foundLove)
{
msg = msg2;
x = length; // do not look for possible second "love"
}
}
}
if(!foundLove && !foundMy)
{
foundHate = false;
for(x = 0; x < length - 5; ++x)
{
if(user.charAt(x) == 'h')
{
if(user.charAt(x + 1) == 'a')
if(user.charAt(x + 2) == 't')
if(user.charAt(x + 3) == 'e')
if(user.charAt(x + 4) == ' ')
if(x >= 1)
{
if(user.charAt(x - 1) == ' ')
foundHate = true;
}
else
foundHate = true;
}
if(foundHate)
{
msg = msg2;
x = length; // do not look for possible second "hate"
}
}
}
if(!foundHate && !foundLove && !foundMy)
{
random = (int) (Math.random() * 100) % 3;
if(random == 0)
msg = msg3;
else
if(random == 1)
msg = msg4;
else
msg = msg5;
}
user = JOptionPane.showInputDialog(null, msg);
}
JOptionPane.showMessageDialog(null, END);
}
}
Learning Journal entry
Use the following questions as guides to self-reflection during this week:
Briefly describe what programming you did this week.
Describe any problems you have had and how you solved your problems.
What skills and knowledge do you recognize that you are gaining, and how will these skills and knowledge be useful in school and as a professional after school?
10 pages
Introductio2
Knight Capital Group is a global finance firm that is based in the United States. The primary services and products offere ...
Introductio2
Knight Capital Group is a global finance firm that is based in the United States. The primary services and products offered by the company include ...
9 pages
Brand Website
This project entails building an alias website for Apple Inc., which primarily features the main product that the company ...
Brand Website
This project entails building an alias website for Apple Inc., which primarily features the main product that the company produces for its consumers. ...
can you do my assignment with extra credit for python ?
node.py:class Node: def __init__(self, initdata): self.data = initdata self.next = None def getData(se ...
can you do my assignment with extra credit for python ?
node.py:class Node: def __init__(self, initdata): self.data = initdata self.next = None def getData(self): return self.data def getNext(self): return self.next def setData(self, newData): self.data = newData def setNext(self, newnext): self.next = newnext--------------------------------------------------------------------------------------------------llstack.py:from node import Nodeclass LLStack: def __init__(self): self.head = None def isEmpty(self): return self.head == None def push(self, item): temp = Node(item) temp.setNext(self.head) self.head = temp def pop(self): item = self.head.getData() self.head = self.head.getNext() return item def length(self): current = self.head count = 0 while current != None: count += 1 current = current.getNext() return count def printList(self): current = self.head while current != None: print(current.getData(), end = " ") current = current.getNext() print()
Similar Content
answer the attached file
basicly it's question for a TAKE HOME EXAM. you are to create a .docs file with the answers.i will attach a outline for a...
MongoDB Atlas Cluster Project Paper
...
BI Advanced Operating System Project
CS 5500
Advanced Operating Systems
Programming Project
by Hyungbae Park
Flowchart - main()
MAIN START
Get user input
(...
Matlab Project with probability
Matlab Assignment (Individual) (probability doc is attached ) This assignment is created as for the fulfi...
JAVA PROGRAMMING QUESTION
(The Fan class ) Design a class named Fan to represent a fan. The class contains: Three cons...
The State University of New Jersey Piscataway Programming Java Computer Coding Task
College level Computer science class Java Programming, 3 hours time limit. Coding ...
Use Case
A case diagram refers to the procedural steps employed in particular business operations. It summarizes relevant use cases...
Response1
Your work is great, it’s easier to understand how the process started from input to output, I like how you have simplifi...
R Code Binomial
# We need to create a binomial distribution according to the above # Let us take the x parameter of the rbinom() to be equ...
Related Tags
Book Guides
Little Fires Everywhere
by Celeste Ng
Dune
by Frank Herbert
The Sun Is Also a Star
by Nicola Yoon
The Power of Habit - Why We Do What We Do in Life and Business
by Charles Duhigg
Catching Fire
by Suzanne Collins
A Passage to India
by E. M. Forster
The BFG
by Roald Dahl
2001 A Space Odyssey
by Arthur Clarke
Get 24/7
Homework help
Our tutors provide high quality explanations & answers.
Post question
Most Popular Content
ECON 120B University of California Confidence Interval Stata Assignment 2
Hi, I need help with a Stata assignment, please follow all the instructions i attached and make sure it runs
ECON 120B University of California Confidence Interval Stata Assignment 2
Hi, I need help with a Stata assignment, please follow all the instructions i attached and make sure it runs
ITS 3105 SUS C Programming Ethics of Artificial Intelligence Paper & Reflection
read the description of the Eliza program at the bottom of this question. Is it ethical to make people think they are talk ...
ITS 3105 SUS C Programming Ethics of Artificial Intelligence Paper & Reflection
read the description of the Eliza program at the bottom of this question. Is it ethical to make people think they are talking to another person when they are not? Does it make a difference if they find the program to be helpful? Would you mind if a Help facility for some software you were using was a machine instead of a person? Have you ever been embarrassed when you thought you were talking to a person but later found out you were not? (For example, have you ever started to respond on the phone only to realize you were listening to an answering machine?)
import javax.swing.*;
public class Eliza
{
public static void main(String[] args)
{
String user;
String msg = "";
String msg1 = "Tell me more about your ";
String msg2 = "You seem to have strong feelings about that";
String msg3 = "Please go on";
String msg4 = "Tell me more";
String msg5 = "Continue";
int random;
int length;
int x, y;
int stopWord;
final String END = "Goodbye";
boolean foundMy = false, foundLove = false, foundHate = false;
user = JOptionPane.showInputDialog(null,
"Hello. I am Eliza, your tharapist. Tell me what" +
"\nis troubling you. Any time you want to quit," +
"\njust type \"Goodbye\"");
while(!user.equalsIgnoreCase(END))
{
user = user.toLowerCase();
length = user.length();
foundMy = false;
for(x = 0; x < length - 3; ++x) // If "my" is at end of sentence, no need to go further
{
if(user.charAt(x) == 'm')
{
if(user.charAt(x + 1) == 'y')
if(user.charAt(x + 2) == ' ')
if(x >= 1)
{
if(user.charAt(x - 1) == ' ')
foundMy = true;
}
else
foundMy = true;
}
if(foundMy)
{
stopWord = length;
for(y = x + 3; y < length; ++y)
{
if(user.charAt(y) == ' ' || user.charAt(y) == '.' || user.charAt(y) == ',')
stopWord = y;
}
msg = msg1 + user.substring(x + 3, stopWord);
x = length; // do not look for possible second "my"
}
}
if(!foundMy)
{
foundLove = false;
for(x = 0; x < length - 5; ++x)
{
if(user.charAt(x) == 'l')
{
if(user.charAt(x + 1) == 'o')
if(user.charAt(x + 2) == 'v')
if(user.charAt(x + 3) == 'e')
if(user.charAt(x + 4) == ' ')
if(x >= 1)
{
if(user.charAt(x - 1) == ' ')
foundLove = true;
}
else
foundLove = true;
}
if(foundLove)
{
msg = msg2;
x = length; // do not look for possible second "love"
}
}
}
if(!foundLove && !foundMy)
{
foundHate = false;
for(x = 0; x < length - 5; ++x)
{
if(user.charAt(x) == 'h')
{
if(user.charAt(x + 1) == 'a')
if(user.charAt(x + 2) == 't')
if(user.charAt(x + 3) == 'e')
if(user.charAt(x + 4) == ' ')
if(x >= 1)
{
if(user.charAt(x - 1) == ' ')
foundHate = true;
}
else
foundHate = true;
}
if(foundHate)
{
msg = msg2;
x = length; // do not look for possible second "hate"
}
}
}
if(!foundHate && !foundLove && !foundMy)
{
random = (int) (Math.random() * 100) % 3;
if(random == 0)
msg = msg3;
else
if(random == 1)
msg = msg4;
else
msg = msg5;
}
user = JOptionPane.showInputDialog(null, msg);
}
JOptionPane.showMessageDialog(null, END);
}
}
Learning Journal entry
Use the following questions as guides to self-reflection during this week:
Briefly describe what programming you did this week.
Describe any problems you have had and how you solved your problems.
What skills and knowledge do you recognize that you are gaining, and how will these skills and knowledge be useful in school and as a professional after school?
10 pages
Introductio2
Knight Capital Group is a global finance firm that is based in the United States. The primary services and products offere ...
Introductio2
Knight Capital Group is a global finance firm that is based in the United States. The primary services and products offered by the company include ...
9 pages
Brand Website
This project entails building an alias website for Apple Inc., which primarily features the main product that the company ...
Brand Website
This project entails building an alias website for Apple Inc., which primarily features the main product that the company produces for its consumers. ...
can you do my assignment with extra credit for python ?
node.py:class Node: def __init__(self, initdata): self.data = initdata self.next = None def getData(se ...
can you do my assignment with extra credit for python ?
node.py:class Node: def __init__(self, initdata): self.data = initdata self.next = None def getData(self): return self.data def getNext(self): return self.next def setData(self, newData): self.data = newData def setNext(self, newnext): self.next = newnext--------------------------------------------------------------------------------------------------llstack.py:from node import Nodeclass LLStack: def __init__(self): self.head = None def isEmpty(self): return self.head == None def push(self, item): temp = Node(item) temp.setNext(self.head) self.head = temp def pop(self): item = self.head.getData() self.head = self.head.getNext() return item def length(self): current = self.head count = 0 while current != None: count += 1 current = current.getNext() return count def printList(self): current = self.head while current != None: print(current.getData(), end = " ") current = current.getNext() print()
Earn money selling
your Study Documents