Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Philos0raptor
Should I apply for a credit card agian?
I recently applied for a citi Thank you card and I was declined because my annual income is too low. I am currently in college with a part time job. I decided to apply for the regular citi thank you card because I am graduating soon. Now that I have been declined can I apply for the citi thank you card for college students instead? Or should I wait?
9 AnswersCredit7 years agoDiscrete Math Question?
I am reviewing for an exam and I have come upon 5 problems that I'm having trouble with. It would be great help if someone can assist me with these 5 problems. Thank you!
1. ∀xp(x) ∧∀yp(y)≡
2. 2. Apply the resolution rule to the statements p v q v r and p v ~q v s
3. If s is a rational numbers, is s2 always a rational number? If it is, give a proof. If it isn’t, give a counterexample.
4. In the domain of integers, If n2 is even, is n always even? If it is, give a proof. If it isn’t, give a counterexample.
5. Let x < y have the usual meaning in the domain of real numbers (“x is strictly less than y”). Write a predicate logic statement that means “Among any two different numbers one of them is strictly less than the other.”
2 AnswersMathematics7 years ago2014 Mazda 3?
I'm in the market to purchase a 2014 Mazda 3 S Grand Touring Hatchback. There is a Mazda dealer near where I live that has a special on a new 2014 Mazda 3 S Grand Touring sedan. The special is as follows:
2014 Mazda 3 S Grand Touring Sedan
MSRP: $26,790
Dealer Discount: -$2000
Sale Price: $24,790
Owner Loyalty Rebate: -$1000
NET COST: $23,790
I'm curious, can this discount be applied to a 2014 Mazda 3 S Grand Touring Hatchback? The hatchback has the exact MSRP as the sedan at $26,790. Also what is an owner loyalty rebate? Thank you!
4 AnswersMazda7 years agoCan someone help me with my java menu?
I have crated a menu in java but I need help inserting records in to a database and deleting a record and searching the database.
The following is the menu:
import java.util.Scanner;
public class Assignment1 {
public Assignment1() {
}
public static void main(String[] args) {
Scanner choose = new Scanner(System.in);
String choice = null;
while (!"end".equals(choice)) {
System.out.println("Welcome to the database menu!\n");
System.out.println("Press 1 to insert a new record");
System.out.println("Press 2 to delete a record");
System.out.println("Press 3 to search the database (by last name)");
System.out.println("Press 4to quit");
choice = choose.nextLine();
if ("1".equals(choice)) {
System.out.println("You choose option 1");
choice = null;
}
if ("2".equals(choice)) {
System.out.println("You choose option 2");
choice = null;
}
if ("3".equals(choice)) {
System.out.println("You choose option 3");
choice = null;
}
if ("4".equals(choice)) {
System.out.println("Good bye!");
choice = null;
exit();
}
choose.close();
}
private static void exit() {
System.exit(0);
}
}
1 AnswerProgramming & Design8 years agoI need help converting Java to C++?
I wrote a program in java and I'm having trouble converting it into C++. Can someone help me convert it into C++ please! Thank you! This program synchronizes a professor and students during office hours.
package program.pkg4.cs.pkg4450;
import java.util.Random;
public class Program4CS4450 {
public static void main(String[] args) {
System.out.println("Available for office hours\n");
Random randomGenerator = new Random();
Class c = new Class();
Professor p = new Professor();
QAPool qp = new QAPool();
c.setProf(p);
p.setClass(c);
int random = randomGenerator.nextInt(4)+1;
p.setAnswer(qp.Answers(random));
int randomInt = randomGenerator.nextInt(10);
Student s1 = new Student("Tim", qp.Questions(randomInt), c);
int randomInt2 = randomGenerator.nextInt(10);
Student s2 = new Student("Bob", qp.Questions(randomInt2), c);
int randomInt3 = randomGenerator.nextInt(10);
Student s3 = new Student("John", qp.Questions(randomInt3), c);
int randomInt4 = randomGenerator.nextInt(10);
Student s4 = new Student("Steve", qp.Questions(randomInt4), c);
int randomInt5 = randomGenerator.nextInt(10);
Student s5 = new Student("Bill", qp.Questions(randomInt5), c);
int randomInt6 = randomGenerator.nextInt(10);
Student s6 = new Student("Larry", qp.Questions(randomInt6), c);
int randomInt7 = randomGenerator.nextInt(10);
Student s7 = new Student("Mark", qp.Questions(randomInt7), c);
int randomInt8 = randomGenerator.nextInt(10);
Student s8 = new Student("Newton", qp.Questions(randomInt8), c);
s1.start();
s2.start();
s3.start();
s4.start();
s5.start();
s6.start();
s7.start();
s8.start();
}
}
class QAPool
{
String Question;
String Answer;
public String Answers (int n)
{
if (n == 1) Answer = "Yes";
if (n == 2) Answer = "I don't know";
if (n == 3) Answer = "Maybe";
if (n == 4) Answer = "It depends";
return Answer;
}
public String Questions(int n)
{
if (n == 1) Question = "Did I pass?";
if (n == 2) Question = "Can you raise my grage?";
if (n == 3) Question = "Are you teaching next quarter?";
if (n == 4) Question = "Have you graded the midterms?";
if (n == 5) Question = "Can I request for an extension on the project?";
if (n == 6) Question = "Will you be available next week?";
if (n == 7) Question = "Do you accept late work?";
if (n == 8) Question = "Did you just give me an 'F'?!";
if (n == 9) Question = "Can I sit in your other class?";
if (n == 0) Question = "Can I see your answer key?";
return Question;
}
}
class Class
{
Professor prof;
public void setProf(Professor p)
{
prof = p;
}
public synchronized void QuestionEnd(String msg, String name)
{
System.out.println(name + " says : " + msg);
prof.AnswerStart(name);
System.out.println("\n");
}
}
class Student extends Thread
{
String name;
String ques;
Class cl;
Student(String n, String q, Class c)
{
name = n;
ques = q;
cl = c;
}
public void run()
{
String message = ques;
for(int i = 0; i < 2; i++) // ask the same question twice !
{
if (i == 1){
message = "I just want to hear it again. " + ques;
}
cl.QuestionEnd(message, name);
//ask a question and wait or sleep before you ask again.
try
{
Thread.sleep(1500); // sleep for 1.5 sec.
}catch(Exception ex){System.out.println("error : " + ex);}
}
}//run
}
class Professor
{
String Prof = "Professor Simth";
Class cl;
String ans;
public void setAnswer(String n)
{
ans = n;
}
public void setClass(Class c)
{
cl = c;
}
public void AnswerStart(String name)
{
System.out.println(Prof + " says : " + ans + ", " + name);
}
}
1 AnswerProgramming & Design8 years agoI need help covering into cin and cout?
I want to ask that in below program if i want to change printf and scanf into cin and cout becuse when I am changing my program into cin and cout it's not running properly.
#include<iostream>
#include <stdio.h>
int main()
{
int q[20],p[50],c=0,c1,d,f,i,j,k=0,n,r,t,b[20],c2[20];
printf("Enter the number of pages:");
scanf("%d",&n);
printf("Enter the reference string:");
for(i=0;i<n;i++)
scanf("%d",&p[i]);
printf("Enter the number of frames:");
scanf("%d",&f);
q[k]=p[k];
printf("\n\t%d\n",q[k]);
c++;
k++;
for(i=1;i<n;i++)
{
c1=0;
for(j=0;j<f;j++)
{
if(p[i]!=q[j])
c1++;
}
if(c1==f)
{
c++;
if(k<f)
{
q[k]=p[i];
k++;
for(j=0;j<k;j++)
printf("\t%d",q[j]);
printf("\n");
}
else
{
for(r=0;r<f;r++)
{
c2[r]=0;
for(j=i-1;j<n;j--)
{
if(q[r]!=p[j])
c2[r]++;
else
break;
}
}
for(r=0;r<f;r++)
b[r]=c2[r];
for(r=0;r<f;r++)
{
for(j=r;j<f;j++)
{
if(b[r]<b[j])
{
t=b[r];
b[r]=b[j];
b[j]=t;
}
}
}
for(r=0;r<f;r++)
{
if(c2[r]==b[0])
q[r]=p[i];
printf("\t%d",q[r]);
}
printf("\n");
}
}
}
printf("\nThe number of page faults is %d",c);
}
1 AnswerProgramming & Design8 years agoAssembly language/ Motorola 68k microprocessor question.?
I have been working on a shot clock program that counts down from 24 sec to 0 and it buzzes. I have encountered some problems. The clock does count down from 24 sec to 0 and it buzzes but I'm having trouble looping it back to 24 seconds. For some reason it loops to 99 sec. Also I'm implementing a keyboard character "s" to resent the clock back to 24 sec at any given time but I'm not getting any results. Please! I need help!
* SHOTCLK.SRC
DUART EQU $00C001 ;68681 base address
OPR_SET EQU 14*2
OPR_CLR EQU 15*2
ACR EQU 4*2
TBA EQU 6
CTUR EQU 6*2
CTLR EQU 7*2
IMR EQU 5*2
IVR EQU 12*2
STOP EQU 15*2
COUNT EQU 57600
TIMESTRT EQU $FFFF24FF ;SHOT CLOCK TIME
I2VECTOR EQU 26
PIA EQU $010001
CRA EQU 1*2
STEP EQU 16
COUNT2 EQU 50
HTOA EQU $00099E
RBA EQU 6 ;Offset for transmit buffer A
NAME MOVEA.L #BANNER,A1 ;send test message to
TRAP #1 ;console
ORG $8000
TIME JMP >INIT
JMP >L2ISR
* Pointers
INIT MOVEA.L #DUART,A0 ;A0 points to 68681
MOVEA.L #DIGITS,A1 ;A1 points to digits
* initialize MC14499 and BCD codes
MOVE.B #7,OPR_CLR(A0)
MOVE.L #TIMESTRT,(A1)
MOVE.B #$FF,4(A1)
MOVE.B #2,5(A1)
* initialize interrupts
MOVE.B #$08,IMR(A0)
MOVE.B #I2VECTOR,IVR(A0)
MOVE.W #COUNT,D0
MOVEP.W D0,CTUR(A0)
MOVE.B #$70,ACR(A0)
ORI.W #$0700,SR
ANDI.W #$F9FF,SR
MAINLOOP
* L2ISR - Level-2 Interrupt Service Routine.*
L2ISR MOVEM.L A0-A3,-(SP)
MOVEA.L #DUART,A0
MOVEA.L #DIGITS,A1
TST.B STOP(A0) ;clr interrupt source
TST.B >BUZZER
BEQ.S OFF
MOVE.B #$07,TBA(A0)
SUBQ.B #1,>BUZZER
OFF SUBQ.B #1,TIMEOUT-DIGITS(A1)
BNE.S SKIP
MOVE.L #BUZZERSET,A3
CMPM.L (A1)+,(A3)+
LEA.L -4(A1),A1
BNE STUFF
MOVE.B #5,>BUZZER
SHOT_POS MOVE.B RBA(A0),D0
CMP #'s',D0
BNE STUFF
STUFF MOVE.B #2,TIMEOUT-DIGITS(A1)
BSR UPDATE2
MOVEA.L #DIGITS+3,A1
MOVEA.L #INC+1,A2
MOVE.W #$04,CCR ;clear X, set Z
SBCD -(A2),-(A1) ;Decrement seconds
CMP.B #$60,(A1) ;SECONDS > 59
BLT.S SKIP
CLR.B (A1)
LEA 1(A2),A2
SKIP2 CMP.B #$13,(A1)
BNE.S SKIP
MOVE.B #$F1,(A1)
SKIP MOVEM.L (SP)+,A0-A3
RTE
* UPDATE2 - send 8 BCD digits to two MC14499s.*
UPDATE2 MOVEM.W D0-D5/A2,-(SP)
LEA 4(A1),A2
MOVE.W #4,D5
LOOP3 MOVE.B #1,OPR_SET(A0)
MOVE.B (A2),D0
BSR.S OUT4
SUBQ.W #2,D5
MOVE.W 0(A1,D5.W),D0
MOVE.B #4,D3
LOOP4 ROL.W #4,D0
BSR.S OUT4
SUBQ #1,D3
BNE LOOP4
TST.W D5
BNE LOOP3
MOVE.B #1,OPR_CLR(A0)
MOVEM.W (SP)+,D0-D5/A2
RTS
* OUT4 - send 4 bits to the MC14499.*
OUT4 MOVEM.W D0-D4,-(SP)
ROR.B #2,D0
MOVE.B #4,D3
LOOP2 ROL.B #1,D0
MOVE.B D0,D2
ANDI.B #$04,D0
MOVE.B D0,OPR_CLR(A0)
EORI.B #$04,D0
MOVE.B D0,OPR_SET(A0)
MOVE.B #$02,D4
MOVE.B D4,OPR_SET(A0)
NOP
NOP
MOVE.B D4,OPR_CLR(A0)
MOVE.B D2,D0
SUBQ #1,D3
BNE LOOP2
MOVEM.W (SP)+,D0-D4
RTS
INC DC.B 1 ;increment for BCD add
ORG $A000 ;data segment (digits)
DIGITS DS.B 4 ;4 bytes, 8 digits
DP DS.B 1 ;decimal points
TIMEOUT DS.B 1 ;counter for timeouts
BUZZER DC.B 0
MOVEA.L #PIA,A0 ;A0 -> DDRA
MOVE.B #$FF,(A0) ;Port A = output
MOVE.B #$04,CRA(A0) ;A0 -> Port A
CLR.B D0 ;init D0 = 0
LOOP MOVE.B D0,(A0) ;send to MC1408L8
ADD.B #STEP,D0 ;inc D0 by STEP
MOVE.W #COUNT,D1 ;create cheap-and-dirty
DBRA D1,* ; software delay
BRA LOOP ;do it again!
BANNER DC.B $0D,$0A,'*** Shot Clock ***'
DC.B $0D,$0A,0
BUZZERSET DC.L $FFFF00FF ;TIME BUZZER GOES OFF
END TIME
1 AnswerProgramming & Design8 years agoMaterials Science Questions?
4NH_3+5O_2→4NO+6H_2 O
What mass of oxygen, O_2, is required to completely combust 400g of NH_3?
What mass of H_2 O is produced?
1 AnswerChemistry8 years agoWhat is the output of this function?
int Fun(int n)
{
If (n==0)
return 2;
else
return 4 + fun(n/2);
}
4 AnswersProgramming & Design8 years agoI need C++ programing help?
I am writing a program that requires a 1.Class specification file (header file) and 2. a Implementation File. I have finished writing my 1. Class Specification file and I was wondering if someone can check correct if I wrote my 2. Implementation file correctly. I have posted the assignment below and my codes below.
**************Assignment**********
Book Store Program
You would like to write a program that functions similarly to a book store data base. Your program should read book data
from an inventory file called books.dat that contains best selling book titles, prices, and number of copies. Your program
should store this data in a linked list (each node will contain a title, price, copies, and link to another node).
Your program should allow a user (book store owner) to do several things:
* Type in a title and retrieve the number of copies available.
* Find titles that need to be reordered - this should be done if the number of copies is less than 10.
* Delete a book and its inventory
* Print the book titles in order of price (least to greatest)
* print the list of inventory (all fields).
Add each routine individually and test it before going on to another routine.
************* 1. My Class specification file (header file)****** CORRECT
#include < string>
using namespace std;
class Store
{
private:
string title;
int reorder;
int delete;
double bookprices;
public:
int numOfCopies(string title);
void FindTitleReoreder();
void DeleteBook(int delete);
void PrintBookPrices();
void PrintAll();
};
*************** 2. Implementation file********NEEDS TO BE CHECKED AND CORRECTED Please!
#include "Store.h"
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
/*
private:
string title;
int reorder;
int delete;
double bookprices;
*/
int Store::numOfCopies(string title)
{
return();
}
void Store::FindTitleReoreder()
{
reutrn(reorder);
}
void Store::DeleteBook(int delete)
{
return(delete);
}
void Store::PrintBookPrices()
{
return(bookprices);
}
void Store::PrintAll()
{
return();
}
1 AnswerProgramming & Design8 years agoC++ programing help please?
I am writing a program that requires a Class specification file (header file) and I was wondering if someone can check if I wrote my Class specification file correctly. I have posted the assignment below and my code below.
**************Assignment**********
Book Store Program
(Use a linked list class similar to that presented in ch 17)
You would like to write a program that functions similarly to a book store data base. Your program should read book data
from an inventory file called books.dat that contains best selling book titles, prices, and number of copies. Your program
should store this data in a linked list (each node will contain a title, price, copies, and link to another node).
Your program should allow a user (book store owner) to do several things:
* Type in a title and retrieve the number of copies available.
* Find titles that need to be reordered - this should be done if the number of copies is less than 10.
* Delete a book and its inventory
* Print the book titles in order of price (least to greatest)
* print the list of inventory (all fields).
Add each routine individually and test it before going on to another routine.
*************My Class specification file (header file)******
#include <string>
using namespace std;
class Store
{
private:
string title;
double reorder;
double delete;
double bookprices;
public:
double FindTitle();
void FindTitleReoreder();
double DeleteBook();
void PrintBookPrices();
void PrintAll();
};
1 AnswerProgramming & Design8 years agoHelp with C++ questions?
1. I need help Declaring a class called Grade. A grade will consist of a score from 1..100, and a grade A,B,C,D,F, and a name.
Write a default and a parameterized constructor for this class.
Write a set method for this class to set all fields.
Write a print method to print the fields.
The grade should be found from the following: 90 and above = A, 80-89 = B, 70-79 = C, 60-69=D, less than 60 F.
Write a driver that creates an array of 5 Grade objects. In the driver call a function that prints all scores that are greater than 80.
consider the following code:
struct ListNode
{
char value;
struct ListNode *next;
};
ListNode *head;
2. Assuming that a linked list has been created and head points to the first node. Write code that traverses the list displaying the contents of each node’s value member
1 AnswerProgramming & Design8 years agoI need help with C++ program.?
Hi! I need help writing a C++ program which uses a data structure class called Movie. this class has a title, rating, and lastly profit data members. I also need create an array of movie objects in my main function.
The program will ask the user for their choice, then it execute's the choice they made. The choices are below. the choices are a function in the main. I need methods to access the data member fields of the movie object.
1) FindParticularRating: Allow a user to enter a movie name and find its rating.
2) FindHighestRating: Print the movie with highest user rating
3) FindHighestBoxOffice: Find Movie with highest box office rating
4) PrintAll: Print all the movies in the array as well as their rating and profits
Below is the file of movies I will be reading from.
5
Fast Five
8.3
192797249.00
Titanic
8.1
20851050.00
Toy Story
8.8
27535632.00
Space Jam
7.8
16250721.00
Rocky
8.7
124647565.00
1 AnswerProgramming & Design9 years agoI need help interpreting what the lines of code mean.?
My teacher wrote this code in class but he is not going to be in class for the rest of the week. Can you please help me interpret this code. Thank you!
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
using namespace std;
struct Infomation
{
string Name;
string Address;
string City;
string State;
string Zip;
string Telephone;
double Balance;
string Date;
};
vector < Infomation > Bank;
bool more();
Infomation takeIn();
void myFlushCin();
void NewAccount();
void Contents();
void DisplayAll();
void EditAccount( int );
int main()
{
for(;;) Contents();
}
bool more()
{
cout << "Anything else y/n ? ";
int reply = cin.get();
if(reply != '\n') myFlushCin();
return reply=='y' || reply=='Y';
}
void myFlushCin()
{
while( cin.get() != '\n' );
}
Infomation takeIn()
{
Infomation file;
bool ok;
do
{
cout << "Enter name: ";
getline( cin, file.Name );
cout << "Enter address: ";
getline( cin, file.Address );
cout << "Enter city: ";
getline( cin, file.City );
cout << "Enter State: ";
getline( cin, file.State );
cout << "Enter zip code: ";
getline( cin, file.Zip );
cout << "Enter telephone: ";
getline( cin, file.Telephone );
cout << "Enter date: ";
getline( cin, file.Date );
for(;;)
{
cout << "Please enter your balance: ";
cin >> file.Balance;
if( !cin.good() )
{
cout << "\nInvalid Entry! Please enter numbers only!\n";
cin.clear();
myFlushCin();
continue;
}
myFlushCin();
break;
}
cout<< "\nYou have entered... " << endl;
int a =45;
cout<< left;
cout<< setw(a) << "Your name is " << file.Name << endl;
cout<< setw(a) << "Your address is " << file.Address << endl;
cout<< setw(a) << "Your current city of residence is " << file.City << endl;
cout<< setw(a) << "Your current state of residence is " << file.State << endl;
cout<< setw(a) << "Your zip code is " << file.Zip << endl;
cout<< setw(a) << "Your current telephone number is " << file.Telephone << endl;
cout<< setw(a) << "Your late date of payment is " << file.Date << endl;
cout<< setw(a) << "Your late recorded account balance is " << file.Balance << endl;
cout<< right;
cout << "Confirm y/n ? ";
int reply = cin.get();
if(reply != '\n') myFlushCin();
ok = (reply=='y' || reply=='Y');
}
while(!ok );
return file;
}
1 AnswerProgramming & Design9 years agoC++ help with structure program.?
I need help writing a program that uses a structure to store the following data about a customer account:
Customer name
Customer address
City
State
ZIP code
Telephone
Account balance
Date of last payment
This program should use an array of at least 20 structures. It should let the user enter data into the array, change the contents of any element, and display all the data stored in the array. The program should have a menu-driven user interface.
Prompts And Output Labels. Your main menu should be the following:
1. Enter new account information
2. Change account information
3. Display all account information
4. Exit the program
The user is expected to enter 1 or 2 or 3 or 4.
The main menu is displayed at the start of the program and after the handling of choices 1, 2 and 3.
If 1 is entered for the main menu, the program prompts for each of the data listed above, in the order listed above, using the above data descriptions (e.g. "ZIP code") as prompts (followed in each case by a colon). After reading in and processing the data, the program prints
You have entered information for customer number X
where X is the customer number: 0 for the first customer and increasing by 1 for each subsequent customer that is entered.
If 2 is entered for the main menu, the program prompts for the customer number:
Customer number:
Upon entering a valid customer number the program displays all the data for the particular customer that has been saved:
Customer name: ...
Customer address: ...
City: ...
State: ...
ZIP code: ...
Telephone: ...
Account balance: ...
Date of last payment: ...
The program then skips one or two lines and prompts for a change, using the same prompts as in choice 1 above for all the data items associated with a customer.
If 3 is entered for the main menu, the program displays all the data for each customer that has been saved, using the display format in choice 2 above. After the display of each customer the program prompts "Press enter to continue..." and waits for the user to hit return.
If 4 is entered for the main menu, the program terminates.
Input Validation (OPTIONAL).When the data for a new account is entered, be sure the user enters data for all the fields. No negative account balances should be entered.
Thank you! I am really struggling with this program.
3 AnswersProgramming & Design9 years agoI need help with this C++ program. Thank you?
I have the catinthehat.dat file. I just need help with the coding part. Thank you!
Write a program with three functions: reverse, upper, lower.
Like upper and lower, reverse should also accept a pointer to a c-string. As it steps through the string, it should test each character to determine whether it is upper or lowercase. If a character is uppercase, it should be converted to lowercase. Likewise, if a character is upper case it should be converted to lowercase.
The upper function should accept a pointer to a c-string as an argument. It should step through each character in the string, converting it to uppercase.
The lower function, to should accept a pointer to a c-string as an argument. It should step through each character in the string converting it to lower case.
Test on a file called: catinthehat.dat
Count each character as it is read into the file and then dynamically allocate an array that will hold these characters
=>Pass the array to the functions in the following order: reverse, lower, and upper.
2 AnswersProgramming & Design9 years agoI need help with a couple C++ questions.?
1) Write a function that accepts a pointer to a C-string as its argument. The function should count the number of times the character ‘w’ occurs in the arguments and return that number.
2) Write a function that takes a char array as a parameter. The function should go through the array and count how many chars are alphabetic, digits, or punctuation.
3)Write a function that converts a lowercase letter to upper case and upper case to lower case. The function should return the changed character.
4) Write a function that takes a character array and its size as a parameter. The function should dynamically allocate a new array that is twice the size of the parameter array. It should then copy the items in the parameter array to the new array. The function should return a pointer to the new array.
5) Write a function that sums all the columns of a 4 by 3 array of integers.
6) Write a function that takes a 1-D array of chars and a single char. The function should locate the single char in the array using a binary search and should return true if the char is found or false if it is not.
1 AnswerHomework Help9 years agoI need help with this C++ programing. Thanks?
Can some one please check my code. I have a few errors that I can not get rid of. Please check my work to see if I have done it correctly and some feed back please. Thanks!
Here are the instructions to this program:
Write a program that reads 20 names from a file called names.dat and stores them in two different arrays (eg names1, names2). Print the unsorted array then modify the selection sort routine so that it sorts the 20 names in the first array. Count how many swaps are needed to sort the 20 names. Print the sorted array contents and the number of swaps needed.
Next, sort the second array with the bubblesort routine. Count how many swaps are needed to sort the array with bubblesort. Print the unsorted array and the sorted array as you did previously along with the number of swaps needed.
Use functions for a well structured program and don't forget your name and program description.
*BELOW IS THE MY CODE*
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
bool searchList(char [], int, char);
void selectionSort(char[], int);
const int SIZE = 10;
int main()
{
ifstream inFile;
inFile.open("/Users/ptrinh/Documents/Xcode files/HW 2/names.txt");
if (!inFile){
cout << "File was NOT found" << endl;
return 1;
}
{
int i=0;
string names[10];
while (!(inFile.eof())){
getline (inFile,names[i]);
cout << names[i] << endl;
i++;
}
inFile.close();
}
return 0;
}
//***************************************************
// Function selectionSort. *
// This function uses the selection sort algorithm *
// to sort the array passed as an argument. The *
// parameter size holds the number of elements. *
//***************************************************
bool searchList(char [], int, char);
void selectionSort(char[], int);
void selectionSort(char array[], int size)
{
ifstream inFile;
inFile.open("/Users/ptrinh/Documents/Xcode files/HW 2/names.txt");
if (!inFile){
cout << "File was NOT found" << endl;
return 1;
}
{
int i=0;
string names[10];
while (!(inFile.eof())){
getline (inFile,names[i]);
cout << names[i] << endl;
i++;
}
int startScan, minIndex, minValue;
for (startScan = 0; startScan < (size - 1); startScan++)
{
minIndex = startScan;
minValue = array[startScan];
for(int index = startScan + 1; index < size; index++)
{
if (array[index] < minValue)
{
minValue = array[index];
minIndex = index;
}
}
array[minIndex] = array[startScan];
array[startScan] = minValue;
}
inFile.close();
}
//***************************************************
// Function searchList. *
// This function searches the list array for the *
// number passed into value. If the number is found *
// the function returns true. Other wise, it returns*
// false. *
//***************************************************
void selectionSort(char[], int);
bool searchList(char array[], int numElems, char value);
{
ifstream inFile;
inFile.open("/Users/ptrinh/Documents/Xcode files/HW 2/names.txt");
if (!inFile){
cout << "File was NOT found" << endl;
return 1;
}
{
bool found = false;
int first = 0,
last = numElems - 1,
middle;
while (!found && first <= last)
{
middle = (first + last) / 2;
if (array[middle] == value)
found = true;
else if (array[middle] > value)
last = middle - 1;
else
first = middle + 1;
}
return found;
}
1 AnswerProgramming & Design9 years agoEngineering Resume Question?
Hi I am currently an engineering student. I wish I apply for an internship at a engineering company. I have finished my resume but I need some feed back on my objective. Here is the objective: "Engineering student seeking an internship opportunity to work with an esteemed engineering company that will allow me to utilize my engineering skill to benefit the company and to improve my career in the engineering field."
2 AnswersOther - Careers & Employment9 years agoJust wondering about apple?
Why doesn't apple sell unlocked iphone 4s in the US? Instead of just providing it to at&t. Wouldn't they make more money?
1 AnswerLaptops & Notebooks1 decade ago