Major Scale And Sequence Loop

Jan 30, 2015

I'm trying to figure out how to print the Major Scale of any give note in music. It works as follows:

There are 12 notes and each note is assigned a number

C = 0, C# = 1, D = 2, D# = 3, E = 4, F = 5, F# = 6, G = 7, G# = 8, A = 9, Bb = 10, B = 11.

After picking a random note, say F, the idea is to add the following sequence to move through the scale:

0, +2, +2, +1, +2, +2, +2, +1.

So, with F being 5, we move through the scale as 5, 7, 9, 10, 0, 2, 4, 5.

The theory is unimportant but, as you can see, the sequence loops back on itself, rather than continue past 11. This is where I'm stuck, though. I'm not clear on how to loop my numbers around in code. I'll show my attempt here:

public static void main(String[] scale) {
majorScaleOf(0); //0 represents C!!
majorScaleOf(5); //5 represents F!!
majorScaleOf(10); //Bb = B flat!!

[Code] ....

For the sake of simplicity I haven't shown the entire script of 'if' statements, but you get the idea.

The print out reads as:

0, 2, 4 (For C)
5, 7, 9 (For F)
10 (For Bb)

The last line demonstrates the problem, as I need it read as 10, 0, 2.

I've tried different approaches, but wanted to convey the basic problem with this post.

View Replies


ADVERTISEMENT

YES / NO Loop In Fibonacci Sequence

Mar 23, 2014

Fibonacci Sequence Code:

public class FibSeqByIanNeumann {
public static void main(String[] args) {
Scanner get = new Scanner(System.in);
int ctr, num1, num2, fib, maxTimes;
System.out.print("How many sequences do you want?: ");
maxTimes = get.nextInt(); //inputs the maxium limit of the fib sequence
 
[code]....

how to do a simple YES/NO Loop so I can try to have it work on my code if I want to try to do the Fibonacci Sequence again.Now I think it might have something to do with a do/while loop.

View Replies View Related

Finding Nth Term In Fibonacci Sequence Using While Loop

Oct 30, 2014

I have to find where in the fibonacci sequence a at number belongs, using a while loop.

Example

>55 is a Fibonacci number whose order in the sequence is 11
>35 is not a Fibonacci number. However, it lies between Fibonacci numbers 34 (order: 10) and 55 (order: 11)

import java.util.Scanner;
public class While
{
public static void main(String[] args)
{
System.out.println("Welcome to the Fibonacci Sequence Detector");

[Code] ....

View Replies View Related

How To Get Background To Scale

Jan 22, 2015

I am developing in Android Studio and I made a simple background, the actual resolution of the image is 1440 by 2560. I made it that resolution so, 1, it is easier to scale down than up, and 2, in android studio i use a nexus 6 as my preview. When I plugged in my gs4, not a 1440 by 2560 display, the background wouldn't show up when I ran it on my gs4(galaxy s 4). How do i get my background to scale and display on any display size.

View Replies View Related

Counting Using Custom Scale

Aug 6, 2014

I'm having trouble creating a highly efficient algorithm for counting within a custom scale. This problem applies to futures trading, specifically treasuries contracts.

One specific treasury contract has 32 units before rolling over to the next whole number. So, the price scale looks something like this ...

1 0
1 1
1 2
...
1 29
1 30
1 31
2 0
2 1
...
2 30
2 31
3 0
...

If I pick a number (price) at random, let's say 1 28, and I want to add 8 units to that value, I should end up with 2 4. I can do this using brute force, calculating remainders, etc, etc....

View Replies View Related

Fetch Type Of Product From Scale

Sep 11, 2014

Below is current process :

We have an application running successfully where we fetch the weight of product currently on Production Line using Java.

All the products on line belong to same order and are of same type.
User at beginning enter the type of product and starts the production line.
 
Proposed new process: Now client want that multiple type of product can belong to same production order. i.e. on a production line different type of products can come one after other. So we should now fetch the type of product also.
 
The Question : what are different possibilities in which we can find the type of product. Can java fetch color of a box ? If we use scanner on line that scans the product and sends the color information to Java.

Above is just a possibility. Can there be any other parameters that Java can use to differentiate in type of product ?
 
Currently we are clueless. What ever are the possibilities in Java we can propose the same to client. Even if that requires additional hardware.

View Replies View Related

Converting Double Values (0.0-110.0) To A 4.0 Scale (as Used In GPA Calculation)

Sep 3, 2014

I am new to programming, but am working on a program that takes 6 inputted grade averages on a scale of 0.0 - 100.0 (exceptions in the case someone has exceeded the traditional 100.0 limit) and then divides it by 6 and returns the value in a dialog box. However, I want to take the values inputted and convert them to a 4.0 scale (90.0-100.0 = 4.0, 80.0-89.99 = 3.0, etc.) and then get the average of that so that I can return an average on a 4.0 scale. I have been trying to accomplish. Also, as of right now my program only prompts the user for 6 inputs, but I'd like the user to be able to input as many as he/she would like to, I am pasting the code I currently have below.

import javax.swing.JOptionPane;
public class GPA_Calculation1_0 {
public static void main(String[] args) {
String courseOne = JOptionPane.showInputDialog("Enter numeric GPA of Course One: ");//Course one
double numOne = Double.parseDouble(courseOne);

[Code] ....

View Replies View Related

Can Enlarge Image As It Is Print Out By Graphics By Scale Of 2?

Apr 8, 2014

So I have scale, and you can change it, like I print out a bufferedimage read by imageio from a file, can I enlarge it by 2x, because my tiles are too small eventhough they're 16x16, should I decided to decrease my tile grid from 40 to 20, but instead change the scale by 2. Can I enlarge the image as it is put on the screen?

View Replies View Related

Swing/AWT/SWT :: Convolution And Gray Scale Filter

Jun 23, 2014

I implemented the gray scale filter and the convolution filter . If I apply before the grayscale filter convolution and then I can not see the picture, I see pretty much the JPanel that should contain the image. The two filters separately functioning correctly

Code filter grey scale

public BufferedImage greyScale(BufferedImage originalImage) {
BufferedImage destImg = new BufferedImage(originalImage.getWidth(), originalImage.getHeight(), BufferedImage.TYPE_INT_ARGB);
int alpha, red, green, blue;
for (int x = 0; x < originalImage.getWidth(); x++) {
for (int y = 0; y < originalImage.getHeight(); y++) {
int pixel = originalImage.getRGB(x, y);

[code]....

View Replies View Related

How To Sequence Through Components

Mar 28, 2014

I know my problem is my lack of understanding of OOP but I have searched for a solution and can't even seem to get close.This is a very simplified version of what I will need to do. I have a button and six textboxes. When the button is pressed I want to take the text from textbox6 and place it in textbox1, textbox2, textbox3, textbox4, and textbox5.

I need sometthing better then this brut force method.Java Code:

package textboxes;
public class TextBoxesGUI extends javax.swing.JFrame {
public String NewText;
public TextBoxesGUI() {
initComponents();

[code]....

View Replies View Related

How To Check Char Sequence

Jun 12, 2014

I what to check if value is not equal to CharSequence value

I try this but getting error:

Java Code:

private CharSequence testvalue = "";
if (!isEqualTo("BCDEF".contains(testvalue))){
}
public boolean isEqualTo(String s_src, String s_compareTo) {
boolean flag = false;

[Code] .....

View Replies View Related

How To Create A Mathematical Sequence

Sep 17, 2014

I want to declare integers, while the program is running.

I run the program and then I give it via System.in.println an integer and repeat this as long as I want. I want the program to give those integers a name of a certain type for, for example a(i) or a[i], dunno, (it should be handy) and then a(i) represents the the i'th integer I gave the program. My idea is then that I can use those elements by their name just like, if I had declared them in the first place. For example add two integers together. For example I defined a method add+, which waits for 2 integer and then adds them. For example I write:

add

a(2)

a(47)

(then I would get here the result.)

However I don't know, how to let the program count the number of inputs or how to let it declare and use variables.

View Replies View Related

How To Create Mathematical Sequence

Sep 17, 2014

I want to declare integers, while the program is running.

I run the program and then I give it via System.in.println an integer and repeat this as long as I want. I want the program to give those integers a name of a certain type for, for example a(i) or a[i], dunno, (it should be handy) and then a(i) represents the the i'th integer I gave the program. My idea is then that I can use those elements by their name just like, if I had declared them in the first place. For example add two integers together. For example I defined a method add+, which waits for 2 integer and then adds them. For example I write:

add
a(2)
a(47)

(then I would get here the result.)

I don't think implementing the add function is difficult. However I don't know, how to let the program count the number of inputs or how to let it declare and use variables.

View Replies View Related

Displaying ArrayList In Given Sequence

Jan 6, 2014

Jdeveloper 11.1.1.7.0
 
Currently I am having an arrayList which consits of the yearweekno.

Example: 201303, 201402, 201401,201352,201351,201350,201349.
 
which means 01, 02,52,....48 are the weeknumbers.
 
No my question is if I have today's date i.e new java.util.Date...i.e week 01.
 
How do I arrange the ArrayList as below
 
201403 201402 201401 201352 201351 201350 201349
 
That is if current yearweek is 201401 then display should be as above(current week+2, current week, currentweek -4).

View Replies View Related

Finding Longest Zig-Zag Sequence In Array

Oct 26, 2014

From a given array of positive and negative numbers, I have to find the longest SUB-Array which represents a Zig-Zag sequence...

A Zig-Zag sequence means that one number is possitive, the next one negative, the next one possitive, and so on and so on...

Like this: -1, 4, -5, 6, -9, 2, -9 etc....

So that means, if the array looks like this:

1, 4, -2, -5, 6, -9, 1, -4, 9, -8, 7, 4, -3

the longest sub-array which fulfills the requirement is (the part in bold):

1, 4, -2, -5, 6, -9, 1, -4, 9, -8, 7, 4, -3

and I only need it's length, which in this case is: 8

View Replies View Related

Implement Error Catching Sequence

Feb 17, 2014

Whats the best way to implement an error catching sequence.I was developing a program to write to a . csv file. and this is one of the methods in it and how I thought Try/ Catch should be implemented. So I have three different possibilities. Another auxiliary class with some constants:

Java Code:

public class Constants {
/**
* Constant name of the file.
*/
public static final String fileName= "inventory.csv";

[code]....

View Replies View Related

Fibonacci Sequence Using Dynamic Arrays

Feb 12, 2014

public class Fibonacci {
public static void main(String[] args) {
int[] numbers;
numbers = new int[20];
numbers[0] = 0;
numbers[1] = 1;
System.out.println("

[Code] ....

I wrote this program for my Java class to print out the first 20 numbers of the Fibonacci series. My assignment then tells me to Rewrite your program using dynamic array. I'm not sure how to do this.

View Replies View Related

Display Values In Fibonacci Sequence From F0 To F15

Apr 15, 2014

I am attempting a programming exercise to display the values in the Fibonacci sequence from F0 to F15. I understand the concept, but, for some reason my equation is simply creating a resulting string of numbers that simply increase by 2's. As, I know it is supposed to be the sum of the previous F and the F that precedes that one to total the new F number. It seems so simple yet I seem to be far off. As usual, I have worked my code for your review.

/*
* This program calculates the "Fibonacci sequence."
* A "sentinel" is used to limit the extent the calculation.
*/

import acm.program.*;
public class bookFibonacciTest2a extends ConsoleProgram {
/* Specifies the limit value of the calculations */
private static final int SENTINEL = 16;
public void run() {
println ("This program display Fibonacci sequence numbers 0 - 15.");

[Code] .....

View Replies View Related

Finding Nth Number In Fibonacci Sequence

Oct 30, 2014

I have to find where in the fibonacci sequence a at number belongs, using a if or while loop.

Example

>55 is a Fibonacci number whose order in the sequence is 11
>35 is not a Fibonacci number. However, it lies between Fibonacci numbers 34 (order: 10) and 55 (order: 11)

import java.util.Scanner;
public class While {
public static void main(String[] args) {
System.out.println("Welcome to the Fibonacci Sequence Detector");
Scanner in = new Scanner(System.in);

[Code] .....

View Replies View Related

Swing/AWT/SWT :: Else If Statements - Arithmetic Sequence

Apr 1, 2014

So I have one set of If Else If statements. My program calculates just the first comboBox. It is retrieving all the values from the other comboBoxes but I do not understand where to place the other If statement structure so I can calculate the other values I have set for the other objects. I would not like to use a different class for each and I know I have my calculations done right below my current if statement. Could it be left there and where shall I place the other if statements so they get read by my arithmetic sequence?

public void actionPerformed(ActionEvent e)
{
Object source = e.getSource() ;
int deckSiz = (int) Decks.getSelectedIndex() ;
int wheelSiz = (int)Wheels.getSelectedIndex();

[code]....

View Replies View Related

Consider Sequence Of Digits From 1 Through N In Increasing Order

Sep 3, 2014

Consider the sequence of digits from 1 through N (N<=9) in increasing order: 1 2 3 4 N

Insert either a +(for addition) or a - (for subtraction) between each of the digits so that the resultant sum is zero. Print all possible combinations that sum to zero.

Example: Enter a number: 7
1+2-3+4-5-6+7=0
1+2-3-4+5+6-7=0
1-2+3+4-5+6-7=0
1-2-3-4-5+6+7=0

View Replies View Related

Fibonacci Sequence - Calculate Nth Number

Apr 29, 2014

Write a recursive method that calculates the Nth number in the Fibonacci sequence. The first and second numbers in the sequence (the base cases) are both 1. After that, each subsequent number is the sum of the previous two. Stated a bit more formally:

fib(n)={1fib(n−1)+fib(n−2)n<2otherwise

For example, here is the first few numbers in the sequence:

1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...

Your fib method should be part of a class named Fibonacci. In addition to the fib method, the Fibonacci class should have a main method that calls fib(9). If the result doesn't equal 34, you should print an error message. Otherwise, it should print out a message saying that it was successful.

After writing your Fibonacci class, answer the following question: How many times is the fibonacci method called when calculating the 5th number in the sequence?

View Replies View Related

How To Find Longest Descending Sequence Without Arrays

Oct 24, 2014

I am trying to find the longest descending sequence without arrays. So 65124976231 would output 9762.

import java.util.*;
public class HelloWorld {
public static void main(String[] args){
String num = "";
int longestLen = 0;
int currLen = 0;
String max = "";

[Code]...

I keep getting: The longest descending sequence is: 6512 In an infinite loop.

View Replies View Related

Draw Architecture / Context And Sequence Diagrams

Jan 1, 2015

I have to submit my system for a hospital management system(java) and i have been asked to draw the following diagrams

Architecture Diagram
Context Diagram
Sequence Diagram

How to draw ???

View Replies View Related

Fibonacci Application - Store Its Sequence In Array

Mar 12, 2014

Modify the Improved Fibonacci application to store its sequence in an array. Do this by creating a new class to hold both the value and a boolean value that says whether the value is even, and then having an array of object references to objects of that class.

Did I just need to declaring the variable in other class (for boolean value and the value itself) or else ?

Here is the code for ImprovedFibonacci.java

Java Code:

class ImprovedFibonacci {
static final int MAX_INDEX = 9;
/**
* Print out the first few Fibonacci numbers,
* marking evens with a '*'
*/
public static void main(String[] args) {
int lo = 1;
int hi = 1;
String mark;

[Code] ....

View Replies View Related

Fibonacci Sequence - Find Sum Of Even-valued Terms

May 14, 2015

I am not sure what is wrong with my code? The code produces a negative number when I type in 4000000 into the fib method parameter.

Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:

1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...

By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.

Java Code:

public static void fib(int k) {
int result = 0;
int[] array = new int[k];
array[0] = 1;
array[1] = 2;
for (int i = 2; i < k; i++) {

[Code] ....

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved