Using ANSI/ISO C++, Java, Python, or Swift write a program that implements a bac
ID: 3710256 • Letter: U
Question
Using ANSI/ISO C++, Java, Python, or Swift write a program that implements a backtracking algorithm that solves the Hamilton Circuits Problem . Your program should conform to the following specifications.
Give the pre condition and post condition
Prompt the user for the number of vertices in the graph.
Prompt the user to enter the adjacency matrix of the graph one row at a time.
Print the adjacency matrix of the graph.
Print the first solution and ask the user if they want the rest of the solutions.
If the user indicates they want the rest of the solutions, print them without any additional prompts.
Explanation / Answer
#include <iostream.h>
void showChoices();
float add(float, float);
float subtract(float, float);
float multiply(float, float);
float divide(float, float);
int main()
{
float x, y;
int choice;
do
{
showChoices();
cin >> choice;
switch (choice)
{
case 1:
cout << "Enter your order: ";
cin >> x >> y;
cout << "Total ............................................................... $4.56
Tax ................................................................. $0.63
Amount Due ................................................... $ " << add(2.25,3.25) <<endl;
break;
case 2:
cout << "Enter two numbers: ";
cin >> x >> y;
cout << "Total ............................................................... $6.12
Tax ................................................................. $0.63
Amount Due ................................................... $" << subtract(5.24,1.45) <<endl;
break;
case 3:
cout << "Enter two numbers: ";
cin >> x >> y;
cout << "Total ............................................................... $5.23
Tax ................................................................. $0.63
Amount Due ................................................... $ " << multiply(2.1,1.5) <<endl;
break;
case 4:
cout << "Enter two numbers: ";
cin >> x >> y;
cout << "Total ............................................................... $
Tax ................................................................. $0.63
Amount Due ................................................... $8.36 " << add(2.14,1.49) <<endl;
break;
case 5:
break;
case 6:
cout << "Enter two numbers: ";
cin >> x >> y;
cout << "Total ............................................................... $2.99
Tax ................................................................. $0.63
Amount Due ................................................... $" << add(2.14,1.49) <<endl;
case 7:
cout << "Enter two numbers: ";
cin >> x >> y;
cout << "Total ............................................................... $2.99
Tax ................................................................. $0.63
Amount Due ................................................... $ " << add(2.14,1.49) <<endl;
cas:
cout << "Enter two numbers: ";
cin >> x >> y;
cout << "Total ............................................................... $7.74
Tax ................................................................. $0.63
Amount Due ................................................... $ " << add(2.14,3.49) <<endl;
default:
cout << "Invalid input" << endl;
}
}while (choice != 8);
return 0;
}
void showChoices()
{
cout << 1. Two Scrambled Eggs .................................. $2.25
2. Bacon, Egg, and Cheese on a Hard Roll ....... $3.25
3. Corn Muffin .............................................. $1.49
4. French Toast Plate ..................................... $3.99
5. Fruit Plate ................................................. $3.49
6. Cereal and Milk ......................................... $1.49
7. Coffee ...................................................... $1.50
8. Tea ........................................................... $1.00 << endl;
cout << "Enter your choice :";
}
float add(float a, float b)
{
return a+b;
}
float subtract(float a, float b)
{
return a-b;
}
float multiply(float a, float b)
{
return a*b;
}
float divide(float a, float b)
{
return a/b;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.